Professional Documents
Culture Documents
Linux Command Line Cheat Sheet: File Management File Editing Finding Files
Linux Command Line Cheat Sheet: File Management File Editing Finding Files
3)
KHLeuven – Departement Rega 1/4 Linux Command Line Cheat Sheet (v0.3)
File Packaging and Compressing System Information Process Management
bzip2 compress files date print or set system date and time at queue jobs for later execution
bunzip2 uncompress bzipped files free show memory information bg resume process in the background
gzip (un)compress files hostname show or set the system's name ctrlc interrupt (stop) running process
gunzip uncompress gzipped files last show log of last logged in users ctrlz suspend running process
tar pack or unpack files in tar archive lsof list open files fg bring process to foreground
x extract from archive lspci list all PCI devices kill terminate a process
t list contents of archive lsusb list all USB devices nice change process priority
c create archive ps show current processes ps show current processes
f specify archive filename e/A all processes e/A show all processes
z perform gzip compression display a tree of processes
pstree renice change priority of running process
j perform bzip2 compression
time summarize resource usage sleep delay a process
unzip unpack and uncompress zip files
top display real-time list of processes sudo run command as different user
zip package and compress files q quit top display real-time list of processes
r recursive
uname print system information q quit
a all information w show users and what they run
File System Management uptime show uptime and system load
report filesystem disk space usage w show users and what they run
df Getting Help
h human readable which locate a command on the PATH
fsck check and repair a file system who show who is logged in apropos search manual pages
lsof list open files info read detailed documentation
c select matching processes man view manual pages
i show open network files whatis view command descriptions
mkfs create a file system (i.e. format)
mount mount a file system
mount <device> <mount point>
stat display file or filesystem status
f show file system status
sync flush file system buffers
umount unmount a file system
KHLeuven – Departement Rega 2/4 Linux Command Line Cheat Sheet (v0.3)
& execute command in background
Networking I/O Redirection
<command> &
dig perform DNS lookup | pipe output of cmd 1 to cmd 2 alias create an alias for a command
dig @<server> <name> <type> <command1> | <command2> alias ls='ls color=auto'
host perform DNS lookup < take input from file unalias remove a command alias
t query type <command> < <file> ctrlR search in command history
ifconfig configure a network interface > redirect output to file history list executed commands
netmask specify subnet mask <command> > <file>
up/down enable or disable interface >> append output to file
<command> >> <file>
netcat read/write over a network
2> redirect error stream to file Special keys
l listening mode
<command> 2> <file> ctrl + D End-Of-File (ends standard input)
netstat print network connections
&> redirect output and error stream ctrl + U erase complete line
l show listening sockets <command> &> <file>
p show PID and program name ctrl + W erase last typed word
2>&1 redirect error stream to output
t show TCP
<command> &> <file>
u show UDP Misc
nmap network exploration scanner
ping send ICMP echo requests
Shell Wildcards cal display a calendar
clear clear terminal
route print / manipulate IP routing table * wildcard for zero or more chars
lpq show printer queue
scp secure copy (remote file copy) ? wildcard for zero or one char
scp <user1>@<host1>:file1 \ lpr print files
[abc] exactly one of the listed chars
<user2>@<host2>:<file2> lprm cancel print job
[az] exactly one char from the range
r recursive mail send and receive mail
[!abc] any char that is not listed specify mail subject
ssh SSH client (remote login) s
ssh <user>@<host> [!az] any char not in the range reset re-initialize terminal
tcpdump dump network traffic {go,no} exactly one of the words watch periodically execute program
i specify network interface xargs build complex command lines
telnet communicate over TCP Shortcuts
telnet <host> <port>
<up> scroll through command history Fun and Games
traceroute print network route
<down> " " " " banner show large banner
wget non-interactive downloader
wget <url> <tab> file or command completion fortune print random adage
whois query whois database ~ home directory
cd cd to last visited directory
\ command continues on next line
KHLeuven – Departement Rega 3/4 Linux Command Line Cheat Sheet (v0.3)
aptget install <package>
System Administration aptget remove <package>
passwd change user password rpm RedHat package management
rpm i <package>
su change user ID or become root
rpm e <package>
useradd create new user
shutdown bring the system down
r reboot Scripting
perl execute Perl program
Regular Expressions e execute perl oneliner
n execute for each line in given text file
. any single character p like -n, but prints resulting lines
[ ] one given characters
[aeiou] matches one vowel
[am] matches one of a,b,c,...,m
[^ ] any single char except given
[^09] matches one non-numeric char
^ start of the line
$ end of the line
* 0 or more times
+ 1 or more times
? 0 or 1 times
{x,y} at least x and max y times
( ) groups multiple expressions
([][][])+
| or
(me|you) matches 'me' or 'you'
( ) marks an expression
\n matches n-th marked expression This work is licensed under the Creative
([ao])x\1 matches 'axa' and 'oxo', not Commons Attribution-
'axo' NonCommercial-ShareAlike 2.5
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/2.5/ or
Package Management send a letter to Creative Commons, 543 Howard
Street, 5th Floor, San Francisco, California, 94105,
aptget Debian package management USA.
KHLeuven – Departement Rega 4/4 Linux Command Line Cheat Sheet (v0.3)