Commands to know on Linux
whoami: tells you your logged in username
man: manual pages on various things
  e.g. man man, man cp, man less
clear: clears the screen (also ctrl-L does this)

Options

most commands take options, options are indicated by a leading -, as in

  cp -r -n -v from_here/ to_here/
or long options with two leading dashes
  chown --reference=$HOME a_file

File and directory stuff

pwd: print out the current working directory
ls: list files in current directory
  ls /etc: list files in /etc
  ls /etc/bash*: list files/directories in /etc beginning with "bash"
cd: change working directory
  cd with no arguments takes you to your home directory
  also pushd/popd allow you to save/restore working directories

mkdir: make a directory
rmdir: remove a directory
touch a_file: if a_file does not exist, create it; if it does exist, change its last accessed time to now.
rm: remove a file
mv a_file to_here: move or rename a file
cp: copy a file
ln -- creates links
  ln -s source target -- creates soft (symbolic) link
  ln source target -- creates hard link
  a symbolic link names its target
  a hard link means two or more directory entries point to the same actual file

Misc

head: print the first few lines of a file
tail: print the last few lines of a file
less: view a file, allowing you to scroll up and down
date: print the current date

redirecting standard output

echo hello > a_file
  will write the string "hello" into a file named "a_file", creating it if it does not already exist,
and overwriting it if it does
echo hello >> a_file
  will write "hello" to the end of a_file (appending)

cat a_file
  dumps contents of a_file to the console
less
  views contents of a file
echo a_string
  prints a_string to the console
wc
  word/char/line count of a file
  (very useful for counting things)
see also head/tail/less

piping

you can redirect the output of one program into the input of another, plumbing multiple tools together. This is one of the features of the Linux/*nix command line that makes it so powerful and expressive.

e.g. ls /etc | xargs -n1 basename | sed -e "s/^/hello /" | sort | uniq
(don't ask what this does or the point -- it is a silly made up example)

sort a_file
  sort the lines of a_file and print the result to the console

uniq a_file
  dump contents of a_file, removing duplicate lines

expansions (globs)

  a*b -- all filenames starting with a and ending in b
  a?b -- all filenames of length 3 stating with a and ending with b
  a{b,c}d -- abd acd
  a[b-d]f -- all filenames starting with a, followed by a letter in the range b-d, followed by an f

Misc

diff file_1 file_2
  show differences between two files (printing nothing if and only if the two files are identical)

find starting_dir -name \*.zip
  recursively searches directories for files/folders matching given criteria

grep PATTERN
  PATTERN is a REGULAR EXPRESSION
  grep prints out (by default) those lines which match PATTERN
grep -v PATTERN file_1
  prints those lines which do NOT match PATTERN
See RegularExpressions for more on what PATTERN does.

Space usage

du -- prints disk usage of specified files/dirs
df -- prints how much space is free on a device

Job and command history

history -- prints previous commands
ps -- list processes
top -- process monitor (text terminal)
kill -- send signal (e.g. TERM, KILL, USR1) to numbered process
killall NAME -- send signal to all processes matching NAME
jobs -- list jobs
bg -- make suspended job run in background
fg -- bring background/suspended job to foreground

Compression and Archiving

gzip -- compress a file to make file.gz
gunzip -- decompress file.gz to get file back
tar -- put multiple files together into a 'tape archive'
xz, unxz -- simlar to gzip/gunzip but slower and better compression
bzip2, bunzip2 -- somewhere between gzip and xz

Editors

nano -- a text editor (easier but less powerful than vim or emacs)
emacs -- big powerful thing, some users love it, others hate it
vim -- steep learning curve, aims for minimum of keystrokes, very powerful as well

Misc

alias -- for defining command line shorthands
xargs -- takes text in its standard input and passes these as arguments to a specified command
  e.g.
    ls *.zip | xargs unzip

User related

who -- shows who's logged in
su -- switch user
sudo -- run command as root
passwd -- change password (root can change any password)
chown -- change owner of a file
chmod -- change permissions of a file