Create your own awesome maps

Even on the go

with our free apps for iPhone, iPad and Android

Get Started

Already have an account?
Log In

Unix Power Tools by Mind Map: Unix Power Tools
5.0 stars - 2 reviews range from 0 to 5

Unix Power Tools

Cheat-Sheet für Leute, ohne Erfahrung mit den Möglichkeiten der Unix-Shell TODO-Links zu Manpages TODO-Kochrezept-Liste

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

svn add file/dir

add new entries

man

man -k

RFCs

FileUtils

ln

-s symbolic link

cat

redirect stdin to stdout

direct input from stdin, end with ctrl-d

e.g. cat > file

cat < file | sort -nr

rm, mv, cp

touch

create empty file with current date

set file date to now

lsof

show which processes hold onto which files

find

find dir1 [..dirn] -expr

-name "*name*"

-type d, -type f, -type l

-csize file size, suffixes k,M,G

-ctime +xdays, modifier

-exec cmd {} \;, {} is current file as param, -exec grep -q text {} \;

-print, print current file

-o, alternatives (or), -name "*.~" -o -name "*.bak"

-printf, print information about file, size, directory, name

od

stat

chmod

chmod ugo+-rwx, u user, g group, o other, r read, w write, x execute, s suid

chmod ugo+r -R ., recursive

du

du -s summe

du -h in MB, KB, GB

dirname, basename, pwd

shred

TextUtils

wc

WordCount (lines, words, chars)

-l count lines

uniq

remove duplicates, input has to be sorted

-c number of duplicates

sort

sort lines

-n numerical

-r reverse

-k sort column

diff

diff -u, unified diff

-r recursive

cut

show part of line

-d delimiter

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

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

grep

-r recursive

-e extended grep

-v inverse match

-q quiet, only return value

sed

awk

patch

patch -p level <diff, cuts off "level" of directories off path before applying the patch

-E, remove emtpy files

tail

-n lines show from ed of file

-f follow continous output

ed

scriptable line editor

tee

duplicate output to file and stdout

tr

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

replace character ranges with others

wc

wc -l (zeilen)

Execution

su

xargs

xargs cmd, cmd will be executed with all following params, find . -name "*.log" -print0 | xargs -0 rm, \0 separated list, because of spaces in names

sudo

sudo -u other_user cmd

sudo cmd_as_root

need permission in /etc/sudoers

strace

strace cmd

log system calls of process

screen

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

screen -RDD -S name, create new session or continue existing one with that name

ctrl-a +, h help, c new screen, d detach, k kill screen, n next screen, p previous, esc esc copy/scroll mode

Programming

perl

m4

macro language

rcs

cvs

git

git clone repourl

git branch, show branches

git add, add changed files, git commit -a, git add -u, only add already versioned changed files

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

git checkout [-b] branch, switch branch, mit -b create new branch

git push origin <branch|master>, upload to origin-repo

git pull origin <branch|master>, pull from origin repo

git checkout -- file, drop local changes

git stash, save local changes temporarily

git rebase

svn

svn checkout url

svn commit -m"msg" [file|dir|], commit/upload changes

svn update, pull/download changes from central repo

Compression

tar

tar cvf file.tgz dirs files

tar xvf file.tgz [files]

j for bzip2

gzip

gzip file -> file.gz

gzip -d decompress

gzip -dc decompress to stdout

bzip2

Network

wget

-O output, also -O - for stdout

-c continue

ngrep

netcat/nc

nc -p port, listen on port and write to stdout

ftp

default login anonymous, email

store credentials in .netrc, machine host, login user, password "pass"

rsync

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

-n dry run

ssh

ssh user@host

port forwarding, target host is any host of target network with a running ssh-daemon, ssh -Llocalport:targethost:targetport user@sshd-machine, ssh -Rremoteport:localmachine:localport

-v verbose

ssh-keygen, generate public/private key, -t dsa, -t rsa

scp

scp file user@host:[dir]

telnet

telnet host port

enter telnet shell with ctrl-]

curl

stunnel

SSL-Tunnel non-SSL-able protocols

shell/bash

cmd < file; file as stdin

cmd > file; stdout to file

cmd1 | cmd2 Pipe stdout->stdin

2> stderr

cmd >> file, append stdout to file

cmd1 && cmd2 ; cmd2 only executed if cmd1 sucessful

cmd1 || cmd2 ; cmd2 executed when cmd1 failed

cmd1; cmd2; execute both

´cmd´ Backticks, result (stdout) in variable - old syntax, use: $(...)

for i in expr; do cmd1; cmd2; done

expr e.g. filelist with *.log

file matching

* all

[a-z] lowercase letters

variables/substitution

VAR=expr

VAR=$1, argument1, shift removes arg1

$VAR, Variablenzugriff

${VAR-default}, Standardwert

${VAR#expr}, removes expr from beginning, e.g. ${FILE#prefix_}, ## is greedy

${VAR%expr}, removes expr from end, e.g. ${FILE%.log}, %% is greedy

Prozesse

ps

ps auxww; alle processes of current user, extrawide lines

ps xauf with tree structure

kill

-SIGABRT (9) terminate

-SIGHUP reread settings

-SIGTERM (15) is default

kill -SIGxxx pid

top

killall

z.b. killall java

bash/jobs

bg [id], background current process

fg [id], get backgrounded job to foreground

ctrl-z, stop/pause current job

cmd &, start cmd as background job

nice/renice

change priority of process

nohup

processes with tty-output will continue to run after logout

chroot