Sie sind auf Seite 1von 2

Linux Command Line Cheat Sheet

by Dave Child (DaveChild) via

Bash Commands Bash Variables Command Lists

uname -a Show system and kernel env Show environment cmd1 ; cmd2

head -n1 /etc/issue Show distribution variables Run cmd1 then cmd2

mount Show mounted echo $NAME Output value of $NAME

cmd1 && cmd2
filesystems variable
Run cmd2 if cmd1 is successful
date Show system date export NAME=value Set $NAME to value
cmd1 || cmd2
$PATH Executable search path
uptime Show uptime
Run cmd2 if cmd1 is not successful
whoami Show your username $HOME Home directory

$SHELL Current shell cmd &

man command Show manual for
command Run cmd in a subshell
IO Redirection

Bash Shortcuts cmd < file Directory Operations

CTRL-c Stop current command Input of cmd from file pwd Show current directory

CTRL-z Sleep program cmd1 <(cmd2) mkdir dir Make directory dir

CTRL-a Go to start of line Output of cmd2 as file input to cmd1 cd dir Change directory to dir

CTRL-e Go to end of line cd .. Go up a directory

cmd > file
CTRL-u Cut from start of line ls List files
Standard output (stdout) of cmd to file
CTRL-k Cut to end of line
cmd > /dev/null
ls Options
CTRL-r Search history
Discard stdout of cmd
-a Show all (including hidden)
!! Repeat last command
cmd >> file
-R Recursive list
!abc Run last command starting with
Append stdout to file
abc -r Reverse order

!abc:p Print last command starting with cmd 2> file -t Sort by last modified
abc Error output (stderr) of cmd to file -S Sort by file size
!$ Last argument of previous cmd 1>&2 -l Long listing format
stdout to same place as stderr -1 One file per line
ALT-. Last argument of previous
cmd 2>&1 -m Comma-separated output
stderr to same place as stdout -Q Quoted output
!* All arguments of previous
command cmd &> file
Search Files
^abc^123 Run previous command, replacing Every output of cmd to file
abc with 123 grep pattern files Search for pattern in
cmd refers to a command. files

grep -i Case insensitive

cmd1 | cmd2 grep -r Recursive search
stdout of cmd1 to cmd2 grep -v Inverted search

cmd1 |& cmd2 grep -o Show matched part of

stderr of cmd1 to cmd2 file only

find /dir/ -name name* Find files starting with

name in dir

By Dave Child (DaveChild) Published 28th October, 2011. Sponsored by Last updated 14th January, 2015. Measure your website readability! Page 1 of 2.
Linux Command Line Cheat Sheet
by Dave Child (DaveChild) via

Search Files (cont) Process Management Screen Shortcuts (cont)

find /dir/ -user name Find files owned by ps Show snapshot of processes CTRL-A
name in dir top Show real time processes Activate commands for screen.
find /dir/ -mmin num Find files modifed less
kill pid Kill process with id pid CTRL-A c
than num minutes ago in
pkill name Kill process with name name Create a new instance of terminal.
killall name Kill all processes with names
whereis command Find binary / source / CTRL-A n
beginning name
manual for command Go to the next instance of terminal.
locate file Find file (quick search of
Nano Shortcuts CTRL-A p
system index)
Go to the previous instance of terminal.
File Operations Ctrl-R Read file CTRL-A "

touch file1 Ctrl-O Save file Show current instances of terminals.

Create file1 Ctrl-X Close file CTRL-A A

cat file1 file2 Cut and Paste Rename the current instance.

Concatenate files and output ALT-A Start marking text More screen info at:
CTRL-K Cut marked text or line
less file1
CTRL-U Paste text
View and paginate file1
File Permissions
Navigate File
file file1
ALT-/ End of file chmod 775 file
Get type of file1
CTRL-A Beginning of line Change mode of file to 775
cp file1 file2
CTRL-E End of line chmod -R 600 folder
Copy file1 to file2
CTRL-C Show line number Recursively chmod folder to 600
mv file1 file2
CTRL-_ Go to line number chown user:group file
Move file1 to file2
Search File Change file owner to user and group to
rm file1 CTRL-W Find group
Delete file1
ALT-W Find next
head file1 File Permission Numbers
CTRL-\ Search and replace
Show first 10 lines of file1 First digit is owner permission, second is group
More nano info at:
and third is everyone.
tail file1
Calculate permission digits by adding numbers
Show last 10 lines of file1
Screen Shortcuts
tail -F file1 4 read (r)
Output last lines of file1 as it changes 2 write (w)
Start a screen session.
1 execute (x)
Watch a Command screen -r

Resume a screen session.

watch -n 5 'ntpq -p'

Issue the 'ntpq -p' command every 5 screen -list

seconds and display output Show your current screen sessions.

By Dave Child (DaveChild) Published 28th October, 2011. Sponsored by Last updated 14th January, 2015. Measure your website readability! Page 2 of 2.