Linux CLI Cheat Sheet

less than 1 minute read

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

  1. ; - Separator. Run first command and then second command.
  2. && - Logical and. Run second command only if first command exits successfully.
  3. || - 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

  1. See free memory - free with -m or -g flags
  2. Process viewer - htop

Keyboard shortcuts

ShortcutFunction
Ctrl+CTerminate Process
Ctrl+DExit session/disconnect from a remote connection
Ctrl+LScroll up to clear screen
Ctrl+AGo to beginning of line
Ctrl+EGo to end of line
Alt+F/Alt+BGo one word forward/backward
Ctrl+RReverse i search
Ctrl+GExit reverse i search
Ctrl+K/Ctrl+UCut to the end/beginning of the line
Ctrl+YYank. Paste the cut items
Ctrl+WCut one word at a time

Leave a Comment