Cheatography
https://cheatography.com
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 modification time |
-X |
Sort by fileextension |
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 backgrounded 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 insensitive |
-n |
Show linenumbers |
-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 |
Permissions
chown user:group file |
Change owner to user:group |
chown -R user:group directory |
Change owner to user:group recursively |
chmod bitmask file |
Set permissions to bitmask |
chmod -R bitmask file |
Set permission to bitmask recursively |
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
|
|
Manipulating 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 |
|