Show Menu
Cheatography

Linux Terminal Cheat Sheet (DRAFT) by

A summary of useful linux commands

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

Ls

-l
List view
-a
Show hidden files
-h
Human readable filesizes
-R
Recursive
-r
Reverse sort
-S
Sort by filesize
-t
Sort by modifi­cation time
-X
Sort by fileex­tension

Bash Commands

C-x C-e
Open command in editor
A-.
Paste argument from previous command
C-c
Interrupt process
C-z
Send process to background
fg
Recover backgr­ounded process
C-s
Freeze output
C-q
Resume output
C-r command
Search for command in history (repeat C-r to search back further)

Grep

-r
Recursion
-i
Case insens­itive
-n
Show linenu­mbers
-v
Inverted search
-c
Counts matches per file
-l
List files that match
-L
List files that don't match
grep -options pattern file
 

Tmux

tmux
Start new tmux session
tmux att
Attach to previous tmux session
C-b c
Create window
C-b n
Next window
C-b p
Previous window
C-b d
Detach from tmux session
C-b s
Choose tmux session
C-b w
Choose tmux window
C-b %
Split window horizontal
C-b "
Split window vertical
C-b o
Toggle between panes in current window

Permis­sions

chown user:group file
Change owner to user:group
chown -R user:group directory
Change owner to user:group recurs­ively
chmod bitmask file
Set permis­sions to bitmask
chmod -R bitmask file
Set permission to bitmask recurs­ively
sudo -u username command
Execute command as username
Read = 4, Write = 2, Execute = 1
Add the numbers together to get the correct mask.
Ex: read, write execute = 4+2+1 = 7
Ex2: read, execute = 4+1 = 5
 

Manipu­lating text

C-w
Delete word before cursor
A-d
Delete word after cursor
C-k
Delete until EOL
C-u
Delete until BOL
C-t
Move character backwards
A-t
Move word backwards
C-y
Paste last deletion

Less

gg
Go to BOF
G
Go to EOF
/term
Search for term
?term
Search for term backwards
n
Repeat search
N
Repeat search backwards
q
Quit

Moving around

C-f
Cursor forwards
C-b
Cursor backwards
A-f
Cursor forwards 1 word
A-b
Cursor backwards 1 word
C-e
Cursor to EOL
C-a
Cursor to BOL
C-xx
Jump to BOL and back