Unix Quick Reference
Moving AroundFind out where you are: pwd
Prints the name of the directory you are in (print working directory).
List the files in the current directory: ls
Move to a different directory: cd <dirname>
$ cd public_html/modelingMove up one directory: cd ..
In any filename, .. (two periods) represents the parent directory and . (one period) represents the current directory.
Go back to your home directory from anywhere: cd
Working with files and directoriesCopy a file: cp <old_file> <new_file>
Rename or move a file: mv <old_file> <new_file>
Delete (remove) a file: rm <filename>
Delete an entire directory: rm -r <dirname>
Create (make) a directory: mkdir <dirname>
View contents of a short file: cat <filename>
View contents of a long file: more <filename>
Send command output to a file: <command> > <output_file>
$ ls > output $ cat output myprogram.pl output test.java test.pl
Getting helpSee help file for any command: man <command>
Stands for manual.
Get all that stuff off your screen: clear
I'm in a strange directory and I don't know how to get home: cd
Getting out of a program that won't stop: Ctrl+c
Text editorsEdit a file with the simplest text editor: pico <filename>
Edit a file with a text editor: emacs <filename>
Edit a file with the best text editor: vi <filename>
Compiling and running programsRun a PERL program: perl <filename>.pl
Compile a Java program: javac <ClassName>.java
Run a Java program: java <ClassName>
Logging in and outConnect to another computer: ssh -l <username> <machine>
Doing things fasterTyping filenames: tab key
To quickly type a filename or directory name, type the first few letters and then press the tab key. If you've typed enough letters to differentiate the name from other file and directory names in the current directory, Unix will complete the name for you.
For instance, if the current directory has two subdirectories, foo/ and bar/ and you want to change to bar/, you can type this:
% cd b[tab key]This trick works almost anywhere a file or directory name is needed in a command.
Recalling previous command lines: up arrow
Repeating the last command: !!
Repeating the last command that starts with certain letters:
Other commandsPrint list of running processes: ps
Stop process # n from running: kill -9 <n>
Print date and time: date
Discover the current user: whoami
Print a history of commands you've used: history
Run the command numbered n in the history: !<n>
List contents of a file: cat <filename>
Concatenate two files into a third file: cat <file1> <file2> > <file3>
Make a file executable: chmod a+x <filename> (change mode)
Search for text in a set of files: grep "text" *.java
Find the differences between two files: diff <file1> <file2>
Use a text-based web browser: lynx <website>