next up previous
Next: Emacs Up: unixBasics Previous: Directory and File Handling

Essential unix commands

Navigation

Command      Description
cd d      Change to directory d
cd      Change to your HOME directory
cd ..      Change to a higher directory
cd ~/doc      Change to 'doc' directory in your HOME (abbrv. as ).
pwd      print [current] working directory

File handling

ls d      List files in directory d
ls      list files in the current working directory
ls -l [f...]      List files in detail ("l"ong list)
mkdir d      Create new directory d
rmdir d      Remove directory d
rm f1 [f2...]      Remove file(s) f1...
rm -rf d1 [d2...]      CAREFUL. Recursively remove all files in the directories
mv f1 [f2...] d      Move file f to directory d
mv d1 d2      Rename directory d1 as d2
cp f1 f2      Copy file f1, and name it as f2
cp -r d1 d2      Recursively copy a directory d1, and name it as d2
ln -s realFileName linkName      Create a symbolic link to realFileName and name it as linkName
chmod mode f      Change protection mode of f.
       example: chmod ugo+x doIt.sh

File contents

emacs [f]      Emacs fullscreen editor
more f       
less f      Show file contents of a text file f

Navigation within ``less''
p or ESC-<      Scroll to the beggining
ESC->      Scroll to the end
space      Scroll forward one page (page up)
b      Scroll back one page (page down)
number      type in a number n and it will scroll n lines
/keyword      search for keyword
n      search for the next "keyword"
q      quit the viewing

Misc

grep pattern [f...]      Print lines matching a pattern
cut [-f] [-d] [f]      Extract columns specified by -f (field), -d specifies delimiter.
sort [-n] [f]      Sort, -n means numerically.
wc      Word count
passwd      Change password
alias name1=''name2''      Create command alias (ksh/bash)
unalias name1 [name2...]      Remove command alias name1 ...
ssh node      Login securely to remote node
exit      End terminal session
export name="v"      set environment variable to value v (ksh/bash)

Process Control

CTRL-c      Interrupt processes
CTRL-s      Stop screen scrolling
CTRL-q      Resume screen output
CTRL-z      Suspend current process
ps      Print process status stats
jobs      Print list of jobs
kill %n      Kill job n
kill -9 n      Remove process n
cmd &      Run cmd in background
bg [%n]      Resume background job n
fg [%n]      Resume foreground job n


next up previous
Next: Emacs Up: unixBasics Previous: Directory and File Handling
Naoki Takebayashi 2011-09-13