UNIX Quick Reference


Command Comments Example

Note: UNIX commands and filenames are case sensitive!

man command display manual page for command man ls
cat [file1...filen] concatenate files to output cat out1 out2 > out3
cp file1 file2 copy file1 to file2 cp hw.c junk.c
cp file1...filen dir copy n files to dir cp *.c ../old
cd directory change current directory cd /u/cs370/george
ls [dirname] lists files in dirname ls -ltr
mkdir name create a directory mkdir bin
rmdir name remove a directory rmdir tmp
more file page through file one screen at a time more junk.c
lpr -Pprinter file spool file to printer lpr -Pnext1 output
pwd display name of the present working directory
vi file edit file, see vi Quick Reference vi prog.c
mv file1 file2 move file1 to file2 mv old new
rm file1 [file2...filen] remove the specified files rm a.out
Ctrl-D logout


vi (Visual Editor) Quick Reference


h Cursor left i Insert text before cursor, end with ESC
l Cursor right I Insert at beginning of current line
j Cursor down a Append text after cursor, end with ESC
k Cursor up A Append at end of line, end with ESC
+ Move to beginning of next line o Open new line below cursor
- Move to beginning of previous line O Open new line above cursor
0 Move to beginning of current line r Replace a character
% Move to matching [,],(,),{,} R Replace characters; end with ESC
$ Move to end of current line s Substitute string for a char, end with ESC
w Word forward 4s Substitute string for 4 chars, end with ESC
b Word backward x Delete a character
Ctrl-F Foreward one screen dd Delete a line
Ctrl-B Backward one screen D Delete to end of line
G Go to last line of file d Delete to beginning of line
xG Go to line x dw Delete one word
) Move to next sentence dtch Delete to ch
( Move to previous sentence p Insert last yank or delete after cursor
} Move to next paragraph P Insert last yank or delete before cursor
{ Move to previous paragraph yy Yank line into buffer
/str Search forward for str "chyy Yank into named buffer ch
?str Search backward for str digits Repeat next command that many times
n Repeat last / or ? search . Repeat last command which changed text
fch Find next ch foreward u Undo last change
Fch Find next ch backward J Join next line with this one
ZZ Save file and exit :w Save file and continue
:wq Save file and exit :q! Exit without saving changes