Show Menu
Cheatography

Linux Command Line Cheat Sheet (DRAFT) by

Linux commands

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

grep [OPTIO­N]... PATTERN [FILE]...

-i
case insens­itive
-n
line numbers
-r
recursive
-L
only list files that don't match
* can put multiple file names
* PATTERN is a basic regex by default
* egrep for extended regex

PyTyle3

Ctrl-Alt-v
tile
Ctrl-A­lt-BkSp
untile
Ctrl-Alt-s
⇩ master window space
Ctrl-Alt-r
⇧ master window space
Ctrl-Alt-g
close master
Ctrl-Alt-d
add new master
Ctrl-Alt-c
rotate windows clockwise
Ctrl-Alt-f
float
Ctrl-Alt-q
quit

terminator

Ctrl+S­hift+O
Split horizo­ntally
Ctrl+S­hift+F
Split vertically
Ctrl+S­hift+F
search
(Shift­+)Win+R
rotate windows (count­er)­clo­ckwise
Alt+(a­rrow)
Move terminal focus ...
 

find [-HLP] [path...] [expre­ssion]

-P
never follow symlinks
-L
follow symlinks
[expre­ssion]
* options
-maxdepth #
 
-mindepth #
* tests
(+n,-n,n)
 
-atime n
n*24h
 
-amin n
 
-execu­table
 
-group name
or ID
 
-size n[cwbkMG]
 
-type [bcdpfls]
 
-user name
or ID
 
-writable
* actions
-delete
 
-exec cmd
* path can be specific or .

Refere­ncing previous commands

$?
exit status of last command
$0
$#
# args passed to current script/ function
$*
list of args passed, as a space-­sep­arated string
$@
list of args passed, as a delimited list
$_
most recent arg
$!
PID of last bg command
$$
pid of current shell
$-
option flags used
$n
reference to arg n in last command

Bash History: "­Event Design­ato­rs"

!n
Repeat nth command
!-n
Repeat command n lines back
!!
Last command; synonymous w/ !-1
!string
Most recent command starting with string
!?string?
Most recent command containing string
^str1^str2^
repeat last command, replacing str1 w/ str2
!!:s/str1/str2
synonymous with the above
!$
last arg of last cmd; synonymous w/ !!:$

History "Word Design­ato­rs"

$
last argument
0 (zero)
0th argument, usually the cmd word
n
the nth word (n-1 arg)
^
1st argument (word 1)
%
word matched by most recent ?str? search
*
all words except the 0th (i.e., all args)
Word designator is separated from event by a colon ':' unless it is ^,$,*,-,%.
For example, !!:$ becomes !$.
Words are counted from 0, so the command itself is 0.
Words can be used with events. For example, !foo:3 finds the last command starting with foo, then takes the 3rd word (2nd argument).

History: Modifiers

[g]s/str1/str2
&
repeat prev substi­tution
p
prints resulting command but doesn't execute it
e
removes all but trailing suffix (e.g., .txt)
r
removes trailing suffix, keeps basename
h
removes "­tra­ili­ng" last dir in pathname, keeping "­hea­d" (path to that direct­ory's directory)
t
removes all dirs in path except the last one ("ta­il")
Used after the event and word design­ators.
Gets very complex.
I'm only showing the sed-like ones here.
 

pacman

-S pkg
install
-Su
upgrade all out-of­-date pkgs (prompts for confir­mation 1st)
-Sy
refresh pkg list
-Ql pkg
list all files owned by pkg
-Qs <re­gex>
search for package (local)
-Ss <re­gex>
search repo
-Qi pkg
pkg info (local)
-Si pkg
pkg info (repo)
-R pkg
remove pkg
-Rn pkg
don't back up configs
-Qm
list all pkgs not found in DB (manually installed)
-T
check all depend­encies
-Qc pkg
view changelog
-Qd
packages installed as depend­encies
-Qtd
orphan packages
-Qu
view all out-of­-date pkgs
-Sii pkg
info re: pkg & what other pkgs depend on it
-Sl [repo]
list all pkgs in specified repo
-Suu
downgrade pkgs to version in repo (i.e., if installed from testing repo, downgrade to stable)
-Sw pkg
download but don't install
-Syy
force refresh
-Syu
update + upgrade
-Syu pkg
update + upgrade all, then install pkg if still not there
-U /path/
install from local file (will get depend­encies from repo)