Unix Power Tools

Get Started. It's Free
or sign up with your email address
Unix Power Tools by Mind Map: Unix Power Tools

1. -A x, -B x -x show x lines after, before or after and before the match

2. svn add file/dir

2.1. add new entries

3. man

3.1. man -k

3.2. RFCs

4. FileUtils

4.1. ln

4.1.1. -s symbolic link

4.2. cat

4.2.1. redirect stdin to stdout

4.2.2. direct input from stdin, end with ctrl-d

4.2.3. e.g. cat > file

4.2.4. cat < file | sort -nr

4.3. rm, mv, cp

4.4. touch

4.4.1. create empty file with current date

4.4.2. set file date to now

4.5. lsof

4.5.1. show which processes hold onto which files

4.6. find

4.6.1. find dir1 [..dirn] -expr

4.6.2. -name "*name*"

4.6.3. -type d, -type f, -type l

4.6.4. -csize file size

4.6.4.1. suffixes k,M,G

4.6.5. -ctime +xdays

4.6.5.1. modifier

4.6.6. -exec cmd {} \;

4.6.6.1. {} is current file as param

4.6.6.2. -exec grep -q text {} \;

4.6.7. -print

4.6.7.1. print current file

4.6.8. -o

4.6.8.1. alternatives (or)

4.6.8.2. -name "*.~" -o -name "*.bak"

4.6.9. -printf

4.6.9.1. print information about file

4.6.9.2. size

4.6.9.3. directory

4.6.9.4. name

4.7. od

4.8. stat

4.9. chmod

4.9.1. chmod ugo+-rwx

4.9.1.1. u user

4.9.1.2. g group

4.9.1.3. o other

4.9.1.4. r read

4.9.1.5. w write

4.9.1.6. x execute

4.9.1.7. s suid

4.9.2. chmod ugo+r -R .

4.9.2.1. recursive

4.10. du

4.10.1. du -s summe

4.10.2. du -h in MB, KB, GB

4.11. dirname, basename, pwd

4.12. shred

5. TextUtils

5.1. wc

5.1.1. WordCount (lines, words, chars)

5.1.2. -l count lines

5.2. uniq

5.2.1. remove duplicates, input has to be sorted

5.2.2. -c number of duplicates

5.3. sort

5.3.1. sort lines

5.3.2. -n numerical

5.3.3. -r reverse

5.3.4. -k sort column

5.4. diff

5.4.1. diff -u

5.4.1.1. unified diff

5.4.2. -r recursive

5.5. cut

5.5.1. show part of line

5.5.2. -d delimiter

5.5.3. -f fields (x,x-y,-x,x-)

5.5.4. -b bytes (x-y,-x,x-)

5.6. grep

5.6.1. -r recursive

5.6.2. -e extended grep

5.6.3. -v inverse match

5.6.4. -q quiet, only return value

5.7. sed

5.8. awk

5.9. patch

5.9.1. patch -p level <diff

5.9.1.1. cuts off "level" of directories off path before applying the patch

5.9.2. -E

5.9.2.1. remove emtpy files

5.10. tail

5.10.1. -n lines show from ed of file

5.10.2. -f follow continous output

5.11. ed

5.11.1. scriptable line editor

5.12. tee

5.12.1. duplicate output to file and stdout

5.13. tr

5.13.1. tr 'a-zA-Z' 'n-za-mN-ZA-M' (Cesar encryption)

5.13.2. replace character ranges with others

5.14. wc

5.14.1. wc -l (zeilen)

6. Execution

6.1. su

6.2. xargs

6.2.1. xargs cmd

6.2.1.1. cmd will be executed with all following params

6.2.1.2. find . -name "*.log" -print0 | xargs -0 rm

6.2.1.2.1. \0 separated list, because of spaces in names

6.3. sudo

6.3.1. sudo -u other_user cmd

6.3.2. sudo cmd_as_root

6.3.3. need permission in /etc/sudoers

6.4. strace

6.4.1. strace cmd

6.4.2. log system calls of process

6.5. screen

6.5.1. console multi session manager, continues to run after logout, can be resumed later also after logging in from different machines

6.5.2. screen -RDD -S name

6.5.2.1. create new session or continue existing one with that name

6.5.3. ctrl-a +

6.5.3.1. h help

6.5.3.2. c new screen

6.5.3.3. d detach

6.5.3.4. k kill screen

6.5.3.5. n next screen

6.5.3.5.1. p previous

6.5.3.6. esc esc copy/scroll mode

7. Programming

7.1. perl

7.2. m4

7.2.1. macro language

7.3. rcs

7.4. cvs

7.5. git

7.5.1. git clone repourl

7.5.2. git branch

7.5.2.1. show branches

7.5.3. git add

7.5.3.1. add changed files

7.5.3.2. git commit -a

7.5.3.3. git add -u

7.5.3.3.1. only add already versioned changed files

7.5.4. git commit -m"msg" [files|dir]

7.5.5. git checkout [-b] branch

7.5.5.1. switch branch, mit -b create new branch

7.5.6. git push origin <branch|master>

7.5.6.1. upload to origin-repo

7.5.7. git pull origin <branch|master>

7.5.7.1. pull from origin repo

7.5.8. git checkout -- file

7.5.8.1. drop local changes

7.5.9. git stash

7.5.9.1. save local changes temporarily

7.5.10. git rebase

7.6. svn

7.6.1. svn checkout url

7.6.2. svn commit -m"msg" [file|dir|]

7.6.2.1. commit/upload changes

7.6.3. svn update

7.6.3.1. pull/download changes from central repo

8. Compression

8.1. tar

8.1.1. tar cvf file.tgz dirs files

8.1.2. tar xvf file.tgz [files]

8.1.3. j for bzip2

8.2. gzip

8.2.1. gzip file -> file.gz

8.2.2. gzip -d decompress

8.2.3. gzip -dc decompress to stdout

8.3. bzip2

9. Network

9.1. wget

9.1.1. -O output, also -O - for stdout

9.1.2. -c continue

9.2. ngrep

9.3. netcat/nc

9.3.1. nc -p port

9.3.1.1. listen on port and write to stdout

9.4. ftp

9.4.1. default login anonymous, email

9.4.2. store credentials in .netrc

9.4.2.1. machine host

9.4.2.2. login user

9.4.2.3. password "pass"

9.5. rsync

9.5.1. rsync avr -e ssh dir user@host:dir/

9.5.2. -n dry run

9.6. ssh

9.6.1. ssh user@host

9.6.2. port forwarding

9.6.2.1. target host is any host of target network with a running ssh-daemon

9.6.2.2. ssh -Llocalport:targethost:targetport user@sshd-machine

9.6.2.3. ssh -Rremoteport:localmachine:localport

9.6.3. -v verbose

9.6.4. ssh-keygen

9.6.4.1. generate public/private key

9.6.4.2. -t dsa, -t rsa

9.7. scp

9.7.1. scp file user@host:[dir]

9.8. telnet

9.8.1. telnet host port

9.8.2. enter telnet shell with ctrl-]

9.9. curl

9.10. stunnel

9.10.1. SSL-Tunnel non-SSL-able protocols

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

11.8. chroot