
1. man
1.1. man -k
1.2. RFCs
2. FileUtils
2.1. ln
2.1.1. -s symbolic link
2.2. cat
2.2.1. redirect stdin to stdout
2.2.2. direct input from stdin, end with ctrl-d
2.2.3. e.g. cat > file
2.2.4. cat < file | sort -nr
2.3. rm, mv, cp
2.4. touch
2.4.1. create empty file with current date
2.4.2. set file date to now
2.5. lsof
2.5.1. show which processes hold onto which files
2.6. find
2.6.1. find dir1 [..dirn] -expr
2.6.2. -name "*name*"
2.6.3. -type d, -type f, -type l
2.6.4. -csize file size
2.6.4.1. suffixes k,M,G
2.6.5. -ctime +xdays
2.6.5.1. modifier
2.6.6. -exec cmd {} \;
2.6.6.1. {} is current file as param
2.6.6.2. -exec grep -q text {} \;
2.6.7. -print
2.6.7.1. print current file
2.6.8. -o
2.6.8.1. alternatives (or)
2.6.8.2. -name "*.~" -o -name "*.bak"
2.6.9. -printf
2.6.9.1. print information about file
2.6.9.2. size
2.6.9.3. directory
2.6.9.4. name
2.7. od
2.8. stat
2.9. chmod
2.9.1. chmod ugo+-rwx
2.9.1.1. u user
2.9.1.2. g group
2.9.1.3. o other
2.9.1.4. r read
2.9.1.5. w write
2.9.1.6. x execute
2.9.1.7. s suid
2.9.2. chmod ugo+r -R .
2.9.2.1. recursive
2.10. du
2.10.1. du -s summe
2.10.2. du -h in MB, KB, GB
2.11. dirname, basename, pwd
2.12. shred
3. TextUtils
3.1. wc
3.1.1. WordCount (lines, words, chars)
3.1.2. -l count lines
3.2. uniq
3.2.1. remove duplicates, input has to be sorted
3.2.2. -c number of duplicates
3.3. sort
3.3.1. sort lines
3.3.2. -n numerical
3.3.3. -r reverse
3.3.4. -k sort column
3.4. diff
3.4.1. diff -u
3.4.1.1. unified diff
3.4.2. -r recursive
3.5. cut
3.5.1. show part of line
3.5.2. -d delimiter
3.5.3. -f fields (x,x-y,-x,x-)
3.5.4. -b bytes (x-y,-x,x-)
3.6. grep
3.6.1. -r recursive
3.6.2. -e extended grep
3.6.3. -v inverse match
3.6.4. -q quiet, only return value
3.7. sed
3.8. awk
3.9. patch
3.9.1. patch -p level <diff
3.9.1.1. cuts off "level" of directories off path before applying the patch
3.9.2. -E
3.9.2.1. remove emtpy files
3.10. tail
3.10.1. -n lines show from ed of file
3.10.2. -f follow continous output
3.11. ed
3.11.1. scriptable line editor
3.12. tee
3.12.1. duplicate output to file and stdout
3.13. tr
3.13.1. tr 'a-zA-Z' 'n-za-mN-ZA-M' (Cesar encryption)
3.13.2. replace character ranges with others
3.14. wc
3.14.1. wc -l (zeilen)
4. Execution
4.1. su
4.2. xargs
4.2.1. xargs cmd
4.2.1.1. cmd will be executed with all following params
4.2.1.2. find . -name "*.log" -print0 | xargs -0 rm
4.2.1.2.1. \0 separated list, because of spaces in names
4.3. sudo
4.3.1. sudo -u other_user cmd
4.3.2. sudo cmd_as_root
4.3.3. need permission in /etc/sudoers
4.4. strace
4.4.1. strace cmd
4.4.2. log system calls of process
4.5. screen
4.5.1. console multi session manager, continues to run after logout, can be resumed later also after logging in from different machines
4.5.2. screen -RDD -S name
4.5.2.1. create new session or continue existing one with that name
4.5.3. ctrl-a +
4.5.3.1. h help
4.5.3.2. c new screen
4.5.3.3. d detach
4.5.3.4. k kill screen
4.5.3.5. n next screen
4.5.3.5.1. p previous
4.5.3.6. esc esc copy/scroll mode
5. Compression
5.1. tar
5.1.1. tar cvf file.tgz dirs files
5.1.2. tar xvf file.tgz [files]
5.1.3. j for bzip2
5.2. gzip
5.2.1. gzip file -> file.gz
5.2.2. gzip -d decompress
5.2.3. gzip -dc decompress to stdout
5.3. bzip2
6. Network
6.1. wget
6.1.1. -O output, also -O - for stdout
6.1.2. -c continue
6.2. ngrep
6.3. netcat/nc
6.3.1. nc -p port
6.3.1.1. listen on port and write to stdout
6.4. ftp
6.4.1. default login anonymous, email
6.4.2. store credentials in .netrc
6.4.2.1. machine host
6.4.2.2. login user
6.4.2.3. password "pass"
6.5. rsync
6.5.1. rsync avr -e ssh dir user@host:dir/
6.5.2. -n dry run
6.6. ssh
6.6.1. ssh user@host
6.6.2. port forwarding
6.6.2.1. target host is any host of target network with a running ssh-daemon
6.6.2.2. ssh -Llocalport:targethost:targetport user@sshd-machine
6.6.2.3. ssh -Rremoteport:localmachine:localport
6.6.3. -v verbose
6.6.4. ssh-keygen
6.6.4.1. generate public/private key
6.6.4.2. -t dsa, -t rsa
6.7. scp
6.7.1. scp file user@host:[dir]
6.8. telnet
6.8.1. telnet host port
6.8.2. enter telnet shell with ctrl-]
6.9. curl
6.10. stunnel
6.10.1. SSL-Tunnel non-SSL-able protocols
7. -A x, -B x -x show x lines after, before or after and before the match
8. svn add file/dir
8.1. add new entries
9. Programming
9.1. perl
9.2. m4
9.2.1. macro language
9.3. rcs
9.4. cvs
9.5. git
9.5.1. git clone repourl
9.5.2. git branch
9.5.2.1. show branches
9.5.3. git add
9.5.3.1. add changed files
9.5.3.2. git commit -a
9.5.3.3. git add -u
9.5.3.3.1. only add already versioned changed files
9.5.4. git commit -m"msg" [files|dir]
9.5.5. git checkout [-b] branch
9.5.5.1. switch branch, mit -b create new branch
9.5.6. git push origin <branch|master>
9.5.6.1. upload to origin-repo
9.5.7. git pull origin <branch|master>
9.5.7.1. pull from origin repo
9.5.8. git checkout -- file
9.5.8.1. drop local changes
9.5.9. git stash
9.5.9.1. save local changes temporarily
9.5.10. git rebase
9.6. svn
9.6.1. svn checkout url
9.6.2. svn commit -m"msg" [file|dir|]
9.6.2.1. commit/upload changes
9.6.3. svn update
9.6.3.1. pull/download changes from central repo
10. shell/bash
10.1. cmd < file; file as stdin
10.2. cmd > file; stdout to file
10.3. cmd1 | cmd2 Pipe stdout->stdin
10.4. 2> stderr
10.5. cmd >> file, append stdout to file
10.6. cmd1 && cmd2 ; cmd2 only executed if cmd1 sucessful
10.7. cmd1 || cmd2 ; cmd2 executed when cmd1 failed
10.8. cmd1; cmd2; execute both
10.9. ´cmd´ Backticks, result (stdout) in variable - old syntax, use: $(...)
10.10. for i in expr; do cmd1; cmd2; done
10.10.1. expr e.g. filelist with *.log
10.11. file matching
10.11.1. * all
10.11.2. [a-z] lowercase letters
10.12. variables/substitution
10.12.1. VAR=expr
10.12.2. VAR=$1
10.12.2.1. argument1
10.12.2.2. shift removes arg1
10.12.3. $VAR
10.12.3.1. Variablenzugriff
10.12.4. ${VAR-default}
10.12.4.1. Standardwert
10.12.5. ${VAR#expr}
10.12.5.1. removes expr from beginning
10.12.5.2. e.g. ${FILE#prefix_}
10.12.5.3. ## is greedy
10.12.6. ${VAR%expr}
10.12.6.1. removes expr from end
10.12.6.2. e.g. ${FILE%.log}
10.12.6.3. %% is greedy
11. Prozesse
11.1. ps
11.1.1. ps auxww; alle processes of current user, extrawide lines
11.1.2. ps xauf with tree structure
11.2. kill
11.2.1. -SIGABRT (9) terminate
11.2.2. -SIGHUP reread settings
11.2.3. -SIGTERM (15) is default
11.2.4. kill -SIGxxx pid
11.3. top
11.4. killall
11.4.1. z.b. killall java
11.5. bash/jobs
11.5.1. bg [id]
11.5.1.1. background current process
11.5.2. fg [id]
11.5.2.1. get backgrounded job to foreground
11.5.3. ctrl-z
11.5.3.1. stop/pause current job
11.5.4. cmd &
11.5.4.1. start cmd as background job
11.6. nice/renice
11.6.1. change priority of process
11.7. nohup
11.7.1. processes with tty-output will continue to run after logout