Linux CLI Cheat Sheet
Published:
Some shortcuts that I learned while working with Linux. Most of these are very basic, so if you have even moderate experience working with the Linux shell, you probably won’t find anything new here.
Commands
sudo !!
Run last command with sudo privileges
Separators
- ; - Separator. Run first command and then second command.
- && - Logical and. Run second command only if first command exits successfully.
- || - Logical or. Run second command only if first command fails.
Create multiple folders
mkdir -p folder/{dir1, dir2}/{dira, dirb, dirc}/{1..100}
See directory size
du -sh dirname
Monitor system
- See free memory -
free
with-m
or-g
flags - Process viewer -
htop
Keyboard shortcuts
Shortcut | Function |
---|---|
Ctrl+C | Terminate Process |
Ctrl+D | Exit session/disconnect from a remote connection |
Ctrl+L | Scroll up to clear screen |
Ctrl+A | Go to beginning of line |
Ctrl+E | Go to end of line |
Alt+F/Alt+B | Go one word forward/backward |
Ctrl+R | Reverse i search |
Ctrl+G | Exit reverse i search |
Ctrl+K/Ctrl+U | Cut to the end/beginning of the line |
Ctrl+Y | Yank. Paste the cut items |
Ctrl+W | Cut one word at a time |
Leave a Comment