Quick UNIX Guide


Directory Commands:

 .              current directory

.. parent of current directory

~ your home directory

~cs110 home directory of cs110 account

A path is a list of directory names separated by slashes (/). The path is used to specificy a directory or file in the tree. An absolute pathstarts with a / or a ~ and describes a path from the root of the filesystem or from a home directory. A relative path doesn't start with a / or a ~ and describes a path from the current directory.

 pwd - Print current working directory

pwd Print current directory.

cd - Change current directory

cd or cd ~ Go to your home directory.

cd .. Go to parent (of current) directory.

cd ~cs110j Go to home directory of cs110 account.

cd MP2 Go to MP2 subdirectory of current directory.

cd ~/MP2 Go to your MP2 subdirectory (regardless of where you are).

mkdir - Make a directory

mkdir MP3 Make a new subdirectory of the current directory called MP3.

rmdir - Remove a directory (if it is empty)

rmdir MP3 Remove the MP3 subdirectory of the current directory.

ls - List files and subdirectories

ls List files and subdirectories in current directory.

ls ~/Mail List files and subdirectories of your Mail directory.


File Commands:

  cp - Copy a file to a new name or location

cp calc.java calc2.java Copy calc.java to a new file calc2.java in the current directory.

cp ~cs110j/public_html/mps/mp1/desc . Copy desc from the mp1 subdirectory of the course public directory to the current directory.

cp ~cs110j/public_html/mps/mp1/* . Copy all files from the mp1 subdirectory of the course public directory to the current directory.

mv - Move a file to a new name or location

mv calc.java calc2.java Rename calc.java to calc2.java in the current directory.

mv ../mp1.class . Move mp1.class from the parent directory into the current directory.

rm - Remove a file

rm mp1.class Remove mp1.class


Mail and News Program -- pine:

  pine          Start pine.

q Quit pine.


Text Viewer -- more:

 more program.java               View the contents of a
                                 source code file called 
                                 program.java.

more letter View the contents of a text file called letter.


Text Editor -- emacs:

 xemacs program.java &           (Create and) edit
                                 a source code file called
                                 program.java.

xemacs letter & (Create and) edit a text file called letter.

You can perform most operations using the pull-down menus at the top of the window. See the EWS manual (p. 68) for a quick reference guide.Here are some extras. Note: ``C-'' means that you should hold down the <Control> key while typing the other key, and ``M-'' means that you should press the <Esc> key before typing the other key.

                  C-g                   Kill command

C-x C-s Save buffer

C-x u Undo

C-x C-c Exit emacs

M-x Command mode

Once in command mode (M-x), you can use commands such as these:

goto-line Go to a specific line number.

overwrite-mode Get into/out-of overwrite mode (toggles).

query-replace Search for a string and replace it with another.

line-number-mode Turn on line number indicator.


Compiler -- javac:

  javac program.java             Compile program.java


Making output files -- > and <:

 java program > out1             Run program, putting the
                                 output in a text file called 
                                 out1.

chmod 700 test.1 Make test.1 executable.

test.1 > test.1.out Run mp1, using test.1 as input (instead of the keyboard), and putting the output in a text file called test.1.out.

diff test.1.out test.1.std Check for differences between the output produced in test.1.out and the standard output in test.1.std.


Printing -- lpr:

 lpr -Pl441dcl letter            Send the text file letter
                                 to the printer in room L441
                                 DCL.

lpr -Pl441dcl program.C Send the source code file program.C to the printer in room L441 DCL.

lpq See all of the jobs the printer is working on.

lprm 345 Remove your job from the printer queue (use the number lpq gives you).


On-line Help -- man:

 man man                 Read on-line manual page for the
                         man program.

man ls Read on-line manual page for the ls program.