Show Menu
Cheatography

bash Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

ls

-ah
all / readable
-S
sort SIZE
-t
sort TIME
-X
sort EXTENSION
-r
reverse
.*txt
txt

cd

 

echo

-n
no newline
-e
\t \n

mv

 

compre­ssion

compress / uncompress
gunzip / gzip
zip / unzip / gzip
telnet / ssh
scp / ftp / sftp

mount / umount

 

df / du

 

CMD

func() {
..
}

wc

 

BASICS

'command'
command > /dev/null

misc

\a
alert (BEL)
\b
backspace
\n
new line
\r
carriage return
\t
tab

mkdir / rmdir

 
 

cp

 

cat

 

grep

-v
doesn't match
-n
line number
-c
count matching lines
-i
case insens­itive

file

 

whereis / which

 

more / less

 

cal

 

uname / whoami / users / who

 

shutdown

poweroff
shutdown -h [now | HH:MM]
reboot
-f -v
force | verbose

BASH

$date
read INPUT
readonly INPUT
echo $INPUT
unset INPUT
delete variable
$$
PID
$0
script name
$N
script arguments
$#
number of arguments
$* / $@
all the arguments (all / indivi­dually quoted)
$?
exit status of last executed cmd
$!
PID of the last background cmd
for X in $*

ping / finger

 

kill

 

ps / top / htop

UID
PID
PPID
C
CPU Utiliz­ation
STIME
TTY
TIME
CPU Time
CMD
Starting CMD

sort

-n
numeri­cally
-r
reverse
-f
case insens­itive
+X
ignore first X fields

awk

 

sed

/patte­rn/­action
action
Xp
prints line
Xd
deletes line X
sed '1, 5d'
leave out 1-5
5!d
complement delete
s/p1/p­2/flag
substi­tutes
flag
g
all matches
p
print pattern space
NUMBER
only nth match
i
case insens­itive
-n
line number
sed -e 's/^[[­:di­git­:]]­[[:­dig­it:­]][­[:d­igi­t:]­]/(­&)/g'
\1 \2

find

 

touch / rm