Comprehensive Linux Cheatsheet

Download text file or Fork me on GitHub.

Penguin Colony


Ctrl+Alt TTerminal
Ctrl+Alt FFirefox
Ctrl+Alt HHome
Ctrl+Alt GGedit
Alt F12Run command

Alt F1Minimize window
Alt F2Toggle maximize window
Alt F3Toggle full screen
Ctrl+Alt DMinimize all windows

Ctrl+Alt F1-F6Terminals (tty-s)
Ctrl+Alt F7-F12Xwindows
Ctrl+Alt BkspRestart X
Ctrl+Alt DelLog out
Ctrl+Alt EndShutdown
Super PgUp/PgDnSwitch workspace
Middle mouse buttonPaste selected text


Ctrl LLocation, show path
Ctrl+Shift NNew folder
Ctrl HShow hidden files


Ctrl GFind next
Ctrl+Shift GFind previous
Ctrl+Shift KClear highlights


Ctrl+Shift CCopy
Ctrl+Shift VPaste
Ctrl+Shift TNew tab
Ctrl+Shift WClose tab
Ctrl PgUp/PgDnSwitch tab
Ctrl +/-Zoom
Ctrl DClose terminal
Ctrl SScroll lock


Keys when in emacs mode. You can switch to 'vi' mode with 'set -o vi' command.

Ctrl CInterrupt, erase line
Ctrl AGo to beginning of line
Ctrl EEnd of line
Ctrl UCopy line
Ctrl YPaste line
Alt .Last argument
Ctrl RSearch trough history
Alt *Show all matches for regular expression
Ctrl+Alt EShow current line passed through alias, history and shell expansion
Ctrl X, Ctrl EEdit command in editor
Ctrl PShow last command (same as up arrow)

Awesome Terminal Commands


dpkgLow level package manager for Debian.
-lLists installed packages.
-i <package> (sudo)Installs package from a package file.
apt-getAdvanced Package Tool built on top of 'dpkg'. New command called simply 'apt' is also available. It merges the functionalities of 'apt-get' and 'apt-cache'.
updateUpdates local list of existing packages.
-u dist-upgradeUpgrades by intelligently handling changing dependencies with new versions of packages. To regularly update put this line in 'crontab':
'apt-get update && apt-get -u dist-upgrade'.
upgradeSame as dist-upgrade, but will not remove installed packages or install new ones.
install <package>Also updates single package.
remove <package>Removes package but leaves its configurations.
remove apt-listchangesUseful when Debian can't find a package.
purge <package>Removes package and its configurations. Run 'apt-get autoremove' after to remove all dependencies that are not needed anymore.
autoremoveRemoves unneeded packages.
source <package>Downloads code.
build-dep <package>Installs the build dependencies.
--yesAnswers with 'yes' to most questions (Except the ones that can have potentially harmful consequences).
--force-yesAnswers 'yes' to all questions (Not recommended).
apt-cacheQueries the APT's internal database.
search <keyword>Searches packages like 'apropos', but globally.
show <package>Shows package info like version, dependencies, etc.
showpkg <package>Similar, but also shows the packages that depend on the searched package (reverse dependencies).
policy <package>Shows installed and remote version.
apt-fileAPT package searching utility.
search <file>Search in which package a file is included.
updateUpdates local list of package contents.
aptitudeEnables package browsing (skin for apt-get).
search '~i!~M'Lists installed packages that were not installed as a dependency, with short description of each.
search <package>Package search.

winetricksInstalls wine applications.
update-alternativesMaintains symbolic links determining default commands.
unattended-upgradeAutomatic installation of security upgrades.


apropos <cmd>Searches the manual page names and descriptions (use quotes for phrases).
-aMatches all keywords.
whatis <cmd>Displays one-line manual page description.
whereis <cmd>Locates the binary, source, and manual page files for a command.
which <cmd>Locates only the binary of a command.
wtfTranslates acronyms and filename suffixes.

Install Mantra

./configure --help
sudo make install


suSwitches user.
- <user>Switches to user.
-Switches to root.
manHelp on commands.
<section>Section numbers: 1. Programs, 2. System calls, 3. Library calls, 4. Special files, 5. File formats, 7. Miscellaneous, 8. System administration commands
echoPrints passed text.
-nDoes not add newline at the end.
-eEnables interpretation of backslashed letters.
xargs <cmd>Passes output from one command to arguments of another:
'echo -a | xargs ls'
-tEchoes the command before executing it.
-pEchoes command and asks for confirmation before execution.
-0Input items are separated by null character instead of space.
tee <file>Sends output of a program to specified file and to standard output:
'<cmd_1> | tee out_1.txt | <cmd_2>'
/dev/ttySends output to terminal and to standard output
exprEvaluates passed expression.
1 + 1Prints '2'.
bcEvaluates input. It's basically a calculator, but also provides some control commands.
echo 1 + 1 | bcPrints '2'.
echo "scale=5;3/4" | bcPrints '.75000'.
shRuns command interpreter (shell). Can run a script even if not executable.
-c '<commands>'Starts new non-interactive shell and reads commands from arguments instead of 'stdin'.
To append lines to system configuration file run:
'sudo sh -c 'echo "<text>" >> <file>''
bashRuns bash command interpreter (shell).
-cReads commands from arguments instead of 'stdin'.
-n <script>Checks script for errors.
-xPrints commands before execution. Useful for debugging.
gccGnu C compiler. Run 'g++' for C++ code.
-wSupresses warnings (Only prints errors).
-WallAll warnings.
-gCompile for debugging.
-std=<std>Sets the standard. Suported standards for C are:
'c90', 'gnu90', 'c99', 'gnu99', 'c11' and 'gnu11'.
Suported standarts for C++ are:
'c++98', 'gnu++98', 'c++11' and 'gnu++11'.
'gnu90' and 'gnu++98' are the default options.
-O<level>Optimization level. '0': Reduce compilation time (default), '1-3': - Level of optimization, 's' - Optimize for size, 'g' - Optimize debugging experience.
run-parts <dir>Runs all scripts or programs in a directory.
dateTells and sets date and time.
-s <string>Sets date.
+%T -s "10:13:13"Sets time.
timedatectlControls the system time and date.
set-timezone CETSets timezone.
xclipCopies to clipboard.
mkfifo <pipe>Creates named pipe during that shell session.
mkisofsCreates a DVD/CD image.
genisoimageCreates a DVD/CD image (Debian).
cdrecordWrites to a CD/DVD.
acpiChecks battery.
fdisk -l (sudo)Shows partitions.
shutdownCloses down the system at a given time.
nowTakes you to the single user mode.
-h nowBegins the shutdown procedure, same as 'halt' and 'poweroff'.
-h 11:50At 11:50.
-r nowSame as 'reboot'.
makeUtility that maintains groups of programs.
-qDoesn't run any commands, just returns '0' exit code if everything is up to date or non-zero otherwise.
-BUnconditionally makes all targets.


-dList directory names instead of contents
-SSort by size
-tSort by time
-1One file per line
./*Ls one level deep
-iGet inode number of file (file id). Use 'sudo find / -inum <number>' to find all links that point to same file.
-iInteractive (Prompts before overwrite)
-vVerbose (Explains what is being done)
-RCopy directories recursively
-pPreserve mode, ownership and timestamps
--preserve=allAlso preserves context, links and xattr
-iInteractive (Prompts before every removal)
-vVerbose (Explains what is being done)
-fForce remove (Does not prompt, useful if 'rm' is aliased with '-i')
-RRemoves directories and their content recursively
-pMake parents if needed
lnMakes links to the files
-s <file> <link>Makes symbolic link. If you want to use relative paths you must be in links directory !!!!!!!!!!!!!!!!!!!!!!
-hDisplays humanly readable free disk space
-s <dir>Directory size
mcMidnight commander
Alt oOpen parent dir in another panel
Ctrl oSwitch to bash
find <dir>
-name <file>Search by name
-regex <regex>Use regex for name search
-notInsert before other options to negate
-maxdepth <levels>Descend only to levels deep
-samefile <file>Find all hard links of a file
-xdevDon't descend directories on other filesystems
-inum <inum>Find files with the inode number
-type <f|d|b|...>Find files of type
-deleteDelete found files
-exec <cmd> {} \;Find files and execute command for every found file. '{}' is replaced with filename
-exec <cmd> {} +Find files and execute command with all filenames in place of '{}'
-atime +/-nFind files that were last accessed less or more than n days.
-print0 | xargs -0 <cmd>Sends found files to a command as parameters. Uses 'NUL' character as separator, necessary for filenames with spaces
locate <regex>Similar as 'find' but using index
-iIgnore case
--regexInterprets all patterns as extended regex
-0 | xargs -0 <cmd>Sends found files to a command as parameters.
updatedb (sudo)Update locate index
md5sumPrints md5 sum hash of a file
readRead single line from standard input
-n 1Print after reading one character
-sDo not echo input coming from terminal
shredSecurely remove files
fileDetermine file's type
treeLs in a tree-like (hierarchical) format
installCopy files and set attributes
gpgDecrypt file with password
mktempCreate a temporary file or directory in '/tmp' and returns it's name.
s/<from>/<to> <files>Renames multiple files using 'sed' syntax
rsyncA fast, versatile, remote (and local) file-copying tool
-Hbaz -e ssh'<src_dir> <user>@<host>:<dest_dir>' - Backs up the 'src-dir': '-H' preserves hard links, '-b' renames preexisting destination files (back up), '-a' preserve everything except hard links and '-z' compresses.
cmpCompares two files, similar to diff but also for binaries
statDisplays files status
-c%XTime of last modification of the file
-fFollow link recursively and print files path
xdg-openOpen file with default application for the file type
dialogDisplay dialog box from shell script
watchExecute command periodically


<archive>Universal archive extractor
xvzf <file>.tar.gz (.tgz)Decompress and detar
xvjf <file>.tar.bz2Decompress and detar
-cf <archive>.tar <files>Compress
\*.zipBackslash is necessary so that bash doesn't expand the '*'
-d <dir>Extract into directory (create if doesn't exist)
-r <archive> <dir>Compress whole directory recursively.
-g <archive> <files>Add files to existing archive (grow).
eExtract files from rar archive
zcatCats gziped file

Terminal Multiplexers

screenSwitch between multiple virtual terminals (useful in ssh). Prefix for a command is 'Ctrl a'.
cNew terminal,
aGo to beginning of line,
|New region vertically,
SNew region horizontally,
tabMove to next region,
QClose all but selected region,
XKill the current region,
escEnter copy/scrollback mode -> space: start/stop marking,
kKill window,
tShow time and avg CPU load
tmuxTerminal multiplexer, better screen. Prefix for a command is 'Ctrl b'. Most commands are the same as in 'screen'.
lsShows running sessions
attach [-t <no>]Attach to running session
dDetach from currently attached session
pgupEnter in copy mode and pageup,
[Copy mode,
"Split horizontally,
%Split vertically


"$x"ALWAYS PUT DOUBLE QUOTES AROUND VARIABLE!!!!!!!!!!!!!!! All variables in bash are global!!!!!!!
"$*"Combines all the arguments into single word, separating them with first character of IFS variable. If IFS is not set, space is used. If IFS is null, no separator is used!!!!!!!!! No args provided will result in one empty string being passed on!!!
"$@"Use this instead!!!!! Will retain arguments as-is, so no args provided will result in no args being passed on. This is in most cases what you want to use for passing on arguments. Google: "$@" is right almost everytime, and $* is wrong almost everytime.
"$#"Number of arguments
"$1"First argument
"$0"Name of the script
$'\n'String literal with escape sequences (there is a backslash before n) If you want IFS to be a new line (useful with for loop) you need to: 'IFS=$'\n'' - The dollar forces substitution!!!!! Also if you want 'while read line; do...' to preserve leading spaces and tabs, you need to set IFS=""
$?Exit code of last command (0 - Success)
Ctrl-Z, kill %%Kill looping bash script

test <expr>Same as '[ <expr> ]'. Returns zero exit status if true.
-nIs string non empty
-zIs string empty
=Strings are equal
-ntFile newer than
-otOlder then
-dDirectory exists
-eFile exists
-fIs a regular file
-hIts a symbolic link
-rHas read permission
-wHas write permission
-xHas execute permission
[[ <expr> ]]Same as '[', but without word splitting and filename expansion. And with additional operators: '&&', '||', '<', '>' (lexicographic less, more), and also regular expression matching.
=~Regex comparison operator: '[[ "$HOST" =~ ^user.* ]]'
let <expr>Executes expression: let a="$b"+2

$(command)Same as 'command'
eval <variable>Execute string as command
$RANDOM0 - 32767
input='cat'Getting standard input
-In place of a file name means standard in or out
set -o viSet line editing to vi mode
pushd .Put current dir on stack
popdPop dir from stack
cd -go to last dir
source <script>Run script: for example source /etc/profile (same as . <cmd>)
#!/bin/bashGood practice to insert at beginning of a bash script
PATH="$PATH:<dir>"Adds new directory to path environment variable.
-p <message>Prompt for user input
var=${1:-"<default>"}Setting variable with default value if $1 is empty
getoptsParse parameters/arguments, builtin
getoptGNU version is even better then getopts, not a builtin
while read line; do <commands>; done < <file>Read from file line by line
-rDo not treat backslashes as escape characters
complete -F <completion_function> <cmd>Set completion function for command
complete -p <cmd>Print the completion function for command
compgen -c <pattern>Print all completions for pattern
help <builtin>Display information about builtin command
waitWait for all background processes to end


-eExit if any command fails
-uExit if referencing undefined variable
-o pipefailIf any command in a pipeline fails, its return code is used as the return code of the whole pipeline
IFS=$'\n\t'Remove space from the default Internal Field Separator


sudo !!Run the last command as root
␣<cmd>Execute a command without saving it in the history
!<cmd>Run last command that starts with cmd


<cmd> 2> /dev/nullRedirect error output to 'null'
<cmd> &> /dev/nullRedirect both standard and error output to 'null'
<cmd> >&2Write to stderr
<cmd> 2>&1 | lessAdd stderr to stdout and print it with less (useful for gcc)

Arrays And Lines

Reads line by line from variable. To preserve spaces use 'IFS='.

while IFS= read -r line; do
    echo "... $line ..."
done <<< "$list" — 
${a[1]}Value of the second element of the array
for c in ${a[@]}Iterate over array
${varname:offset:length}Get substring: 's="aeiou"; ${s:3:1} -> o'
${#var}Length of a var
${#name[subscript]}Length of the element
${#name[@]}Length of the array

Aliases And Functions

aliasPrint all aliases
<name>Print alias
<name>='cmd'Set alias
command <cmd>Executes original command, bypassing any aliases or shell functions that may be defined for command
\<cmd>Temporarily disable alias (call original)
type <cmd>Will tell you what is command aliased to or if it is a builtin, function or a command -P just check commands
declare -FPrint function names
declare -fPrint functions



-n-<num_of_lines>Print all lines but the last n
-c <num_of_chars>Print first c characters
-n+<line_num>Start at line number
-fDo not stop printing (follow)
-nNumber all lines
>> fileSimplest text editor (great for pasting)
&<patt>Display only lines with pattern
-NShow line numbers
-~Do not show '~' after 'EOF'
+GTells less to start at the end of the file
+FFollow the input (to scroll up first press ctrl+c)
-FOr --quit-if-one-screen
vOpens editor defined in '$VISUAL' or '$EDITOR'
:nExamine the next file
<, >Go to home, end
wcCount lines, words and characters


sudo -e <file>Edit file as sudo
tr <from> <to>Translate characters
-dDelete characters
cut <file>Removes columns from each line of files
-d ':' -f 1,7 /etc/passwdOnly show the username and the shell
sortSorts lines
-uUniq, removes duplicates
-tSet delimiter for fields (default is space)
-kSelect by which field to sort
uniqRemoves adjacent duplicates
columnColumnate text
-tCreate a table
shufShuffle input lines
tacConcatenate and print files in reverse (reverse 'cat')
joinJoin lines of two files on a common field
[from [to]]Removes columns
seq <number>Output numbers from 1 to number
ispell, aspellInteractive spell checker
basename <path>Strips directory from path
-s .<suffix>Also strip suffix
-aProcess multiple filenames
dirname <path>Strip last component from path
fmtProduce roughly uniform line lengths
foldWrap each input line to fit in specified width
pasteGlue two documents side by side
's///g'Substitute every occurrence in line, not just the first one
's///I'Ignore case
-rExtended syntax, for '+', '?', ... Also you shouldn't escape the parenthesis
-r 's###e'Execute match as a command
-i <file>Will make changes directly to the file (in place)
-uUnbuffered mode (processes input immediately)
-n lPrint escape sequence (keycode) of a pressed key
expandConvert tabs to spaces
-t <number>Set number of spaces (default is 8)
-iDo not convert tabs after non blanks


-u <files>Unified format
--brief -rCompare two directory trees
colordiffVersion of diff with colors
sdiffTwo files side by side
commCompare two sorted files line by line
patchApply a diff file to original
patch < patch.diffApply patch
diff -u <old_file> <new_file> > patch.diffCreate patch


grep <patt> <file>
-nLine numbers
-wWhole word
-A<num>Print also num lines after
-B<num>Print also num lines before
-oPrint only matching part
-PPerl notation with additional operators such as: '\\t', '+' and '?' (non-greedy!!!!).
-iIgnore case
-IDo not process binary files
-lJust print files with matches
-LJust print files without matches
-e <patt>Necessary to put before pattern if it starts with '-'!!!!!!! or if you want multiple patterns.
| wc -lCount occurrences
--line-bufferedProcesses input line by line instead of in bigger chunks
lookDisplay lines beginning with a given string
stringsPrint all text parts of binary file


todos, fromdosConvert line endings form/to windows format (package tofrodos)
enscriptConverts text files to postscript, rtf, HTML
gsGhostscript: postscript and PDF language interpreter and previewer
pdftohtmlPdf to html
pdftotextPdf to text
libreofficeNew Openoffice
figletDisplay large characters made up of ordinary screen characters (Ascii art)
toiletSimilar (Ascii art)
cprotoGenerates C function prototypes (declarations)


nanoSimple text editor.
/etc/nanorcConfig file.
/usr/share/nano/<lang>.nanorcSyntax highlight files.
Alt + / or ?Go to last line.
fteCool text editor with CUA (IBM)-shortcuts
diakonosSimple terminal text editor with ctrl-c for copy
pyroomDistraction free writing (gui)


whoisInfo about domain
host <ip/hostname>DNS lookup utility
nslookupSame interactively
digSame, lot of options
hostnamePrints/sets computer name, to set it permanently edit '/etc/hostname' and '/etc/hosts'
netstatDisplays contents of /proc/net files, status of ports...
-rShow routing table
-iShow interfaces
arpManipulate the system ARP cache (IP -> mac)
routeTool used to display or modify the routing table
add default gw <ip>Change the default gateway should DNS not be configured correctly on your machine, you need to edit '/etc/resolv.conf' to make things work
ifconfig eth0
down/up (sudo)Turn network interface on/off
<ip> netmask <mask> upSet ip and mask
ifup eth0Will bring eth0 up if it is currently down.
link showList network interfaces
link set dev eth0 upBring interface eth0 up or down
addr showList addresses of interfaces
route add default via <ip>Set default gateway
traceroute, traceroute6, traceroute6.iputilsTraces route
tracepath, tracepath6Similar (iputils package)
mtrCombines the functionality of the traceroute and ping
findsmbList info about machines that respond to SMB name queries - Windows based machines sharing their hard disks
/etc/servicesList of internet services with their port numbers
NetworkManagerNetwork management daemon, configuration file is in /etc/NetworkManager/NetworkManager.conf
nm-toolPrints info
nm-onlineIs network connected
nmcliCommand-line tool for controlling NetworkManager
nc(netcat) It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning...
ncatConcatenate and redirect sockets
ethtool eth0Show status of eth0
-sChange settings (speed, duplex,...)
ss -tuplList internet services on a system
-tuoList active connections to/from system


iwconfigSets the wireless configuration options basic to most wireless devices
iwlist wlan0
<option>Displays current status information of a device, more detailed then iwconfig
scan (sudo)List wireless networks in range
iwspySets the list of IP addresses in a wireless network and checks the quality of their connections
iwprivAccesses configuration options specific to a particular device
listShow wireless adapters (wifi and bluetooth)
block/unblock <dev_num>Block/unblock wireless device
iw dev wlan0
linkShow link status of wlan0
set biterates <standard>Manually set interface speed
scan (sudo)List wireless networks in range
wavemonMonitor wireless connection link quality


muttMail client
sftpSecure ftp
sshd(openssh-server) ssh server deamon, on Windows service is named 'CYGWIN sshd'

/etc/init.d/ssh restart (sudo)Restart sshd (ssh deamon)
/usr/local/etc/init.d/openssh start (sudo)Start openssh deamon
ssh-keygen -t rsa -C <email>Generate rsa key pair, keys are stored in ~/.ssh

sshSSH client
<user>@<address> "mpg321 -" < <file>.mp3Stream audio over ssh
enter ~.Kill unresponsive session
scpSecurely copy files over network. Example: 'scp <local_file> <user>@<host>:~<remote_file>'
wgetDownload files from WWW
-OSpecify output file
-cContinue downloading unfinished file. Can also use wildcards, but use single quotes around url.
-r -l1 --no-parent -A.gifRecursively to the depth of one ignoring references to the parent directory and all gifs.
-qO -Writes to standard output + quiet
-iUrls specified by standard input
transmissioncliTorrent terminal client
-dDownload limit (kB/s)
-uUpload limit
youtube-dlDownload from YouTube
noip2Dynamic dns update client
rdesktopRemote Desktop Protocol client
tin, nnUsenet client
nrssRss feed reader


lynxTerminal web browser
-cmd_log=<file>Write keystrokes to script
-cmd_script=<file>Read keystrokes from script
-syslog-urlsLog requested URLs with syslog.
-dumbPrints txt to stdout
-crawlSame, turns numbers off
-sourcePrints html to stdout
-lAdd the current link to your bookmark file
aSave the address of a document or link to a bookmark file, by default ~/lynx_bookmarks.html
oOptions (you can select vim mode)
ctrl+nScroll down two lines
ctrl+pScroll up two lines
ctrl+pPrevious line
crrl+nNext line
elinksAnother web browser (has menus)


-sP scanning -p100-139Port scanning
-O (sudo)Scanning os
tcpdump (sudo)Sniffer (show network traffic)
-lBuffered output (for piping to less, etc.)
ettercapMultipurpose sniffer/interceptor/logger for switched LAN (can detect man in the middle, denial of service, DNS spoofing)
driftnetPicks out and displays images from network traffic
kismetWireless 802.11b monitoring tool
aircrack-ngWireless WEP/WPA cracking utilities
Cain & AbelPassword recovery tool for Microsoft Operating Systems
dnsniffWarious hacking tools:
arpspoofFor man in the middle attack
dsniffPassword sniffer for several protocols, ...
ip link set eth0
promisc onSet network interface to promiscuous mode
multicast offSet multicast off


meta, system infoIn cinnamon
uname -aPrint system info, kernel version
cat /etc/issueShow name and version of distribution

initUpstart init daemon job configuration
telinitChange system runlevel
dmesgPrint the contents of your bootup (startup) messages displayed by the kernel. This is often useful when debugging problems
getconf -aPrint all system configuration variables
nohup <cmd>Run a command immune to hangups, runs even after the shell is closed (writes output to nohup.out)
&>/dev/null &Run a command immune to hangups in background, do not save output
wmctrlX Window Manager
awesomeTiled window manager
-kCheck configuration script for errors

busybox <cmd>Combines tiny versions of many common UNIX utilities into a single small executable. (1.5 Mb)
mono.NET support


usersPrints logged in users
whoLogged in users, more data
wLogged in users, also what are they running
vipwEdit password file
vigrEdit groups file
umaskthe umask is a value set by the shell. It controls the default permissions of any file created
usermod <user>Modify user account information
-l <new_name> <old_name>
-c "<new_real_name>" <user>
-d /my/new/home <user>Change location of the users home
-m -d /my/new/homeAlso move the files
useradd <user>Add user
adduser <user>More high level (use 'adduser <user> sudo' after to add user to sudo group)
--systemCreate system user (can not log in)
<group>Add user to group (only takes effect after login!!!)
groups <user>What groups user belongs to
userdel -r <user>Remove user and his home dir
-remove-all-files <user>More high level, removes also files outside home, cron jobs, itd
passwd <user>Change password

File Systems

mkfsBuild a Linux filesystem
mke2fsCreate a ext filesystem
mkswapSet up a swap area
partedPartition manipulation program
-l (sudo)List partitions
fdiskManipulate disk partition table
-l (sudo)List partitions
disksNice GUI partition tool
mountList all mounted devices (to get list of devices use 'fdisk -l')
<device> <path>For example mount /dev/hdc2 to /mymedia
lsattrList file attributes
chattrChange file attributes
rkhunter -cChecks if it can find any rootkits under the system
ntfsundeleteUndelete files on NTFS partition


lastWhen various users have logged in or out. This includes information on when the computer was rebooted.
lastlogDisplays a list of users and what day/time they logged into the system.
To get all failed logins run:
'cat /var/log/auth.log | grep "failed password" -i'.
rsyslogdmanages all the logs on your system closelog, openlog, syslog, vsyslog -> library calls that send messages to the system logger
loggerMakes entries in the system log
zeitgeistActivity logger


tload'graphic' representation of system load
topShow processes by resource consumption
<, >Change resource
htopBetter top
free -tmDisplays memory statistics
-s <seconds>Continuously display
vmstatPerformance of system components / virtual memory statistics
sarSystem activity information
iostatDisk usage
time <cmd>Time a execution of a command


auditdSystem call auditing (package)
ausearchQuerys the audit logs
autraceTraces a specific process
auditctlControls the behavior of the auditd server
strace <cmd>Trace system calls and signals. All printed system calls can be looked up by 'man'!
-sMaximum string size we want printed (default is too short, 2000 is OK)
-fAlso follow children
-p <pid>Attach to process
-o <file>Write output to file
-TTime the execution of each call
ltraceList library calls made by command
lsofList open files with file descriptors
-p <pid>Open files by process
<path>Open files in path
lsmodShow which kernel modules (drivers) are loaded
modinfo <module>Get more information about kernel module


lshw (sudo)List all hardware
lspci [-tv]Show pci info
lsusb [-tv]Show usb info
lscpuPrint CPU information
dmidecode -qDisplay bios/dmi information like ram size/type, max ram, computer model name, cpu information.
-A /dev/sdaShow disk usage info
-tT /dev/sdaDo a read speed test
-s /dev/sdaCheck for bad blocks
fstrim -v /Discard unused blocks, useful for ssd-s
sensors(lm-sensors) hardware monitoring tool, temperature, fan speed
pwmconfig(fancontrol) set fan speed


ttyPrint the file name of the terminal connected to standard input
sttyChange and print terminal line settings
openvtrun a program on a next available tty
scriptMakes a typescript of everything printed on your terminal. Ctrl-d to stop recording.
settermSet terminal attributes
-cursor off/onSet cursor on/off
gpmEnable mouse for tty


In X

xmodmapRemap keys
setxkbmap -layout usSet us keyboard layout
xevGet keycodes of pressed keys
xsetUser preference utility for X
-rTurn key autorepeat off
rTurn key autorepeat on

X Not Necessary

loadkeys <country_code>Load key mapping
showkeyGet keycodes of pressed keys
setfont <font>Set console font
/usr/share/consolefonts/Uni2-VGA16.psf.gzFor example
/etc/default/console-setupcontains the default settings
jfbtermEnable unicode characters in terminal
echo -en "\e]PC7373C9"Change blue color in tty (first numeral after P means slot, and others shade)


ps --forestView hierarchical view of processes
vVirtual memory
--sort <field>Sort by field
pgrep <pattern>Prints PIDs of processes containing pattern
-lAlso print process name
pkill <pattern>Kills every process that contains pattern in name
<pid>Sends TERM signal to process
-kill <pid>Sends KILL signal meaning force quit, data will be lost
killallUses name instead of pid
skillSends signals to command/user/tty or report process status
-stop <user>Stop all of the users processes
-cont <user>Continue all users processes
niceSets the priority for a process (from max of -20 to min of 20)
-20 <cmd>Execute command with maximum priority
reniceChanges the priority of an existing process
+20 <pid>Change processes priority to lowest level
sniceWorks very similarly to skill
-10 -u rootIncrease the priority of all root's processes
pmapReport memory map of a process (mapped file)


Ctrl zPut job into background
jobsPrints currently running job
bg <job_id>Put job in background
fg <job_id>Bring job to the foreground
%nJob number n
%sJob whose command line starts with s
%%Current job
%-Previous job

Scheduled Commands

atExecutes command at a particular time at 21:30 / at now + time / at -f shell_script now + 1 hour echo "ls -l" | at midnight
atqList jobs currently in 'at' queue
atrmRemove a job from the 'at' queue
crontab -eSchedule commands for repeating execution
cronDaemon that executes scheduled commands
sudo service cron statusPrint status of cron
sudo service cron [stop|start|restart]Stop, start, or restart cron deamon
sudo vim /etc/default/cronSet logging lever
cat /var/log/cronPrint log
anacronLike cron but it catches up with tasks next time the computer gets turned on


serviceAllows you to start, stop or restart a service (it runs a script in /etc/init.d folder)
-f sshdRestart the ssh server
httpd statusGet status of apache
--status-allPrint status of all services You can also execute the shell script directly from /etc/init.d folder like: /etc/init.d/httpd stop.

System Runlevels

runlevelOutput previous and current runlevel
0Shuts down the system
1Administrative single-user mode
2Same as 3 but without networking / multiuser with X server
3Text mode state (ctrl+alt+F1) / User defined
4User defined
5X-window mode (ctrl+alt+F7) / User defined
SSingle user mode



alsamixerSet audio level (curses)
amixerSet audio levels (command line)
rmmod pcspkr (sudo)Disable pc-speaker, beep

cmusMusic player (can be controlled from outside)
mplayerMovie/music player
mpg321Plays mp3
ogg123Plays ogg
aplayPlays audio
playPlays audio
arecord <file>Command line audio recorder and player
-f <format>Set file format (cd)
-d <seconds>Set duration
-f cd -d <seconds> -t raw | lame -x -rOut.mp3 — Capture audio that is playing and convert it to mp3
id3v2 -lLists all files tags
sound-juicerCd ripper
xfburnCd burner
traversoSimple daw


displayDisplays an image
montageCreates a montage from images
<input_file/s> -set label '%t' <output_file/s>Labels images
convert <old> <new>Converts file format (imagemagick)
importCaptures screen-shots from the X server
mogrifyEdit image
gocrCommand line text recognition tool
ocradCommand line text recognition tool
ppmforgeCreates picture of random planet or clouds
gnuplotInteractive plotter: plot [-10:10] sin(x)
-pLeave plots open after exit
plot <file>.datPlot data from dat file
fbiDisplay images inside tty


ffmpeg -i <file_in> <file_out>Video and audio format converter. Has been replaced by avconv
avconv -i <file_in> <file_out>Video and audio format converter (libav-tools)

openshotGui movie editor
openmovieeditorGui movie editor
aview, asciiviewASCII art image viewer and video player

Awesome Debian Files


~/.bashrcExecuted at every shell startup, user specific
/etc/bash.bashrcExecuted at every shell startup, all users
~/.profile, .bash_profile, .bash_loginFirst file found executed at login, user specific
/etc/profileExecuted at login, all users (put PATHS here)
/etc/rc.localLast startup script executed, runs command as su


~/.XmodmapKeyboard map


/binKey programs like ls, cat, bash, ...
/sbinKey programs for system management like ifconfig, mkfs, fdisk, ...
/usr/binDistribution managed programs
/usr/sbinDistribution managed system programs
/usr/local/binUser programs not managed by the distribution package
/usr/local/sbinUser system management programs, not managed by the distribution package

General Config

"Edit To Configure" or "Editable Text Configuration".

/etc/mailcapDefault programs for extensions
/etc/defaultBoot script parameters that the end user or administrator is likely to change.
/console-setupSet console (tty) character set, font size, ...
/etc/fstabFilesystem table. To mount drive at startup, create dir in '/media' and append line like this : '/dev/sda1 /media/data ntfs user,fmask=0111,dmask=0000 0 2' (Check 'man fstab' for details).
/etc/alternativesLinks to default application versions (here you can change the default Java JDK)
/etc/issueName and version of distribution
/etc/fstabAutomatic mounts are handled by configuring the file
/etc/sudoersLists of users and the commands they can run with sudo (needs to be edited with visudo command)
/sources.listList of places where to look for packages


/etc/init/, ~/.init/
InitUpstart init daemon job configuration
/etc/init.dFolder with service scripts, that get executed at start and end
/haltRuns at the end
/etc/rc<level>.dStartup scripts for different runlevels - Links to scripts in /etc/init.d - S85httpd -> S means startup, K is for stop. (To disable service just change S for K)
/etc/rc.localLast initialization file executed - Put your commands here

/etc/init/ssh.confSshd config
/etc/ssh/sshd_configSshd config
/etc/crontabSystem-wide crontab
/etc/cron.hourly, /etc/cron.daily, ...Links to scripts that will execute periodically. Scripts within a cron directory are run alphabetically.
/etc/rsyslog.conf | rsyslog.d/50-default.confLog conf (need to restart rsyslogd after edit)
/etc/syslog.confConfiguration information for syslogd


/etc/resolv.confDns information
/networking/devices/ifcfg-eth0Use ifcfg to configure a particular interface
/etc/servicesList of internet services with their port numbers
/NetworkManager.confConfiguration file


Various information about the system.

/proc/cpuinfoInformation about the CPU
/proc/modulesinformation about which kernel-modules are loaded on your system
/proc/netNetwork related
/routeRouting table
/netstatDisplays contents of /proc/net files
/proc/iomemNeat memory map
/proc/partitionsPartitions info
/battery/BAT1/infoBattery info
/ac_adapter/ACAD/stateAdapter info
/wakeupList of devices that can wake up your machine via acpi
sudo sh -c "echo USB1 > /proc/acpi/wakeup"Enable device USB1 to wakeup computer from sleep/suspend
/proc/net/wirelessWireless connection info


"Unix System Resources"

/jvmJava JREs and JDKs
/manMan pages
/bash-completionBash completion functions


The "system-administrator's bin file". Hosts programs that would be in /bin if they didn't have "root-only" access permissions.



/var/logSystem logs in here
/syslogMost of the rest of the logs
/var/spoolContains data which is awaiting some kind of later processing



/boot/grub/menu.lstGrub configuration file
/etc/default/grubGrub configuration file


Git Mantra

git init
git add <file> OR git add .
git status
git commit -am "<commit_message>"

Clone From Github

git clone<user>/<project>Download repo (later you keep refreshing with 'git pull origin master') -> You need SSH key. If you don't want, use<user>/<repo> for address.

Generate Ssh Key

1.Check for existing keys: cd ~/.ssh; ls -al
2.Generate new key: ssh-keygen -t rsa -C ""
3.Add your key to the ssh-agent: ssh-add ~/.ssh/id_rsa
4.Add your key to GitHub: copy contents of ~/.ssh/ and paste them into key field at 'Account settings' > 'SSH Keys' > 'Add SSH key'.

Add To Github

# Create remote repository on website.
git remote add origin<user>/<project>.git
git pull origin master
git push origin master
# Sometimes also: git push --set-upstream origin master


git remote
updateGet info about state of remote
show originPrint address of the origin
set-url origin <origin>'<user>/<repo>.git' - Change the url of origin, ssh key needed; '<user>/<repo>.git' - Same, but withouth key.
git status -unoCheck if everything up-to-date
git fetch; git checkout <branch>Checkout remote branch


git push --tagsPush tags
git fetch --tagsPulling tags (automatically if on the same branch and there is a new commit?)


git reset
--hard HEAD~1Delete last commit and all of its changes
HEAD~1Delete last commit but keep your changes

Also Useful

git checkout HEAD^ <file>Retrieve deleted file
git rm --cached <file>Untrack file without deleting it
git tag -a 0.9.1 -m "Version 0.9.1 release"Tag latest commit
git tagList local tags
chown -R <user>:<group> * (sudo)In .git/objects
git format-patch -1 <sha>Generate patch file
git rev-parse HEADGet sha of head
git revert
git describePrint version and hash of HEAD
git log --name-only --author=<name>Print changed files by commit
git log <file>Print files history
git ls-filesList files
git show <revision>:<file>Take a peek at the older revision of the file
git diff <commit> <commit>Compare two commits
git stashIf you want to switch branches, but you don't want to commit your changes yet, you can 'stash' them
git stash applyApply the changes you stashed
git stash listList all the stashes
git stash show -p stash@{0}Show the diff of most recent stash
git update-index --chmod=+x <file>Change files permissions
git config -lPrint repos configuration settings
git config core.filemode falseIgnores executable bit of the files


git log > ../gitLogFirst save log to file
git checkout <hash>Then checkout previous versions
git checkout headReturn to head

Github Md Format

![Alt text](/doc/basket-stats.png?raw=true "<Description>")Insert image


git bisect start
git bisect badTell git that current version is bad
git bisect good v25.0.2Tell git the last good version you know about. Now git will checkout a version in between, so you can check it and tell:
git bisect bad/goodThis will continue until the commit that introduced the bug is found
git bisect resetExit bisect mode


gitkRepo explorer
gitgA bit nicer version
tigText based repo explorer
gitstatsGenerates stats for git repo, outputs HTML

Virtual Box

git config core.filemode falseIgnores the filemode changes made by the host system
git config --global --unset https.proxyIf problem pulling

+<linenum>Open file at line number
alt+<normal mode key>Escape, key !!!!!!!!!!!!!!!!!
.Execute last command again
;Repeat the last character-wise search
\cCase insensitive search
?Search backward
VLinewise visual mode
~Switch case
>Tab selection right
>>Tab line right
PPaste before cursor
xDelete character
gFOpen file under cursor
KLook up word under cursor in man pages
ctrl+vSelect visual box (block select)
:eReload file
:savSave file as and keep new file open (save as)


ctrl+]Follow link
ctrl+oGo back
:qExit help


eEnd of word
EEnd of WORD
WStart of WORD
geEnd of previous word
), (Sentence
{, }Paragraph
]], [[Section
:<num>Goto line number
ctrl+oGo to previous location
ctrl+iGo to next location
%Jump to matching bracket


0Start of line
^,_First non-blank of line
+,-First non-blank of next/previous line
EnterFirst non-blank of next line

Screen Lines

g0, g$Start/end of screen line
gmMiddle of screen line
gk, gjUp/down one screen line

Page Up/Down

H,M,LGo to top/middle/bottom of screen
ctrl F,BPage up/down
ctrl D,UHalf page up/down
ctrl E,YOne more line at bottom/top
z Enter, z., z-Reposition line with cursor at top/middle/bottom


*,#Search forward/backward for exact word under cursor
g*,g#Same, but even when word is embedded
%Find match of current brace, quote,...
fx,FxMove cursor forward/backward to x on current line
tx,TxSame, but to one char before x
;/,Repeat/reverse last
:%s/old/new/gcReplace, like sed, c means with conformations


'"Move to position of last edit of file
`.Move to last change in file
`0Position where you last exited vim

Insert Mode Commands

ctrl+uDelete line
ctrl+wDelete previous word


q<x>Record actions (macro) into x
qStop recording macro
@<x>Execute x (macro)


"ayyCopy line into register a
"apPaste register a
:regAccess all registers

Set Command

:set <x>Set x
:set no<x>, <x>!Unset x
:set <x>=valueAssign x
:set <x>-=valueRemove value form <x>
:set allPrint all values
:set <x>?Print x

Set Command Operands

autoident, aiAutoident (noai)
backup, bkBack file up before overwrite (nobackup)
ignorecase, icIgnore case in search (noic)
number, nuDisplay line numbers (nonu)
relativenumber, rnuDisplay relative numbers (nornu)
shiftwidth, swNumber of spaces added when indenting (8)
tabstop, tsTab width (8)
wrapWrap lines (wrap)
wrapscan, wsSearch wraps around file (ws)
mouse=aMouse mode (use shift when selecting to copy to clipboard)
linebreakDo not break words

:set iskeyword-=.Remove dot from words part (two words if separated with dot)

Edit Commands

[n] operation [m] motionIf both n and m are specified then n x m

c, d, yChange, delete, yank
C, D, YTill the end of line
cc, dd, yyCurrent line
cf<x>, df<x>, yf<x>Forward up to x
c), d), y)Sentence

~Change case of character
g~wSwitch case of a word
gu, gUTo lower/upper case

[pPaste but match current indentation
rReplace character
SSubstitute entire line
x,XDelete character/delete back
.Repeat last change
ctrl+a, ctrl+xIncrement/decrement number under cursor

Automatic Linebrake (Wrap)

gqFormats (wraps) selected text
gqqFormat current line
:set tw=72Set text width


tw=72 fo=cq wm=0No automatic wrapping, rewrapping will wrap to 72
twControls the wrap width you would like to use
foControls whether or not automatic text wrapping is enabled, depending whether or not the t flag is set
wmControls when to wrap based on terminal size


darkblue, torteNice, darker
slate, defaultLess contrast
:highlight Normal ctermbg=greySet light background


:set spell spelllang=en_usTurn spellcheck on
:set nospellTurn off
:setlocal spell spelllang=en_usSet dictionary
z=Show suggestions for misspelled word
]sGo to next misspelled word
[sGo to previous misspelled word


:tabe <file>Open new tab
gt, gTGo to next/previous tab
ctrl+pgup/pgdnSwitch tab
vim -pOpen one tab page per file
ZZSave and close tab (same as :wq)


:vspSplit vertically
ctrl-w, directionMove to split


ctrl+nShow autocomplete suggestions


:%!xxdConvert to hex
:%!xxd -rConvert back


:PluginInstallInstall plugins

Reformat Code

=Fix indentation


Piratebay torrent file


javac -cp <path>:<path>...Tell Java where libraries are located
java -Xmx6g myprogramReserve 6 giga for process
-jar <jar>Execute jar
-cp .:<path>:<path>...Tell java where libraries are located, you also need to pass the location of class among paths, hence .:
export _JAVA_OPTIONS=-Xmx1000mSet heap space globally
appletviewer <page>.htmlRun Java applet
jps -lvmList java processes
jmap -histo:live <pid>Memory map
jar cvfe "bla.jar" <main_class> *.classCreate executable jar
jar xf <jar>Extract files from jar
jar tf <jar>Print contents of a jar

Install Oracle Jdk

sudo apt-get remove openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Install Oracle Jdk On Debian

echo "deb precise main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src precise main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp:// --recv-keys EEA14886
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java7-set-default


about:configLayout.css.devPixelsPerPx default zoom (-1.0)


--output VGA1 --primaryChanges primary screen
--output VGA1 --auto --pos 0x0'--output LVDS1 --auto --right-of VGA1' - To change their relative positions
-qList devices
--output LVDS1 --offTurn off laptop screen
--output [VGA|HDMI] --mode 1600x120024" 16x12 on

Mount Iso

sudo mkdir /media/x
sudo mount -o loop <path_to_iso> /media/x


ctrl+1Quick fix
alt+shift+sSource submenu
ctrl+F7, escClose pop-up console window
ctrl+7, ctrl+/Toggle comment
F3Goto definition
objectaidUML plugin


winecfgDrives tab to set drive
wine explorer /desktop=abalaba,1024x768 app.exeRun wine app in virtual desktop
reason on wine: down alt downOpen menu
regeditRegistry editor


[cygwin] ssh-host-cofig
[command prompt] net start sshd
[any] ssh <windows_username - CASE MATTERS!>@<host>Run sshd (use windows password)


buildCompile packages and dependencies
cleanRemove object files
envPrint Go environment information
fixRun go tool fix on packages
fmtRun gofmt on package sources
getDownload and install packages and dependencies (first you need to set GOPATH to dir where packages will get downloaded)
installCompile and install packages and dependencies
listList packages
runCompile and run Go program
testTest packages
toolRun specified go tool
versionPrint Go version
vetRun go tool vet on packages

syntax highlight''
for gedit'sudo cp /usr/share/gtksourceview-3.0/language-specs/go.lang /usr/share/gtksourceview-2.0/language-specs/'
simple ncursesGo get

Repackaging A Linux Install Iso

# Mount ISO
mkdir -p /mnt/linux
mount -o loop /tmp/linux-install.iso /mnt/linux
# Copy contents to a working directory
cd /mnt/
tar -cvf — Linux | (cd /var/tmp && tar -xf — )
# Make your changes and repackage (on Debian use genisoimage). -c passes the name of the file that will be created
cd /var/tmp/linux
mkisofs -o ../your-new.iso -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V Your Disk Name Here .


gdb <cmd>Start gdb
run <arguments>Start debugging
run < <file>Run with piped input
upFollow trace
print <variable>Print variable


ulimit -c unlimitedSet core file limit to unlimited
gdb <cmd> coreDebug core file with gdb


F6, ctrl+l, alt+dGo to address bar