ViewertViewert

Linux Terminal Navigation Guide

By Sunrostern · · 3 min read

🧠 Terminal Navigation & Operations Cheat Sheet

1️⃣ Line Editing (while typing a command)

These are gold.

Cursor movement

ActionShortcutStart of lineCtrl + AEnd of lineCtrl + EMove back 1 charCtrl + BMove forward 1 charCtrl + FBack 1 wordAlt + BForward 1 wordAlt + F

Deleting text

  • Delete entire lineCtrl + U

  • Delete cursor → end of lineCtrl + K

  • Delete previous wordCtrl + W

  • Delete char under cursorCtrl + DBackspace⌫

Undo

ActionShortcutUndo last editCtrl + _ (Ctrl + Shift + -)


2️⃣ Command Execution & Control

ActionShortcutRun commandEnterCancel current commandCtrl + CSuspend commandCtrl + ZResume suspended jobfgRun in backgroundcommand &Exit shellexit or Ctrl + D


3️⃣ Command History (🔥 huge productivity boost)

ActionShortcutPrevious command↑Next command↓Search historyCtrl + RRepeat last command!!Repeat last with sudosudo !!Run command #!123Last argumentAlt + .

Pro tip

During Ctrl + R, keep pressing Ctrl + R to cycle matches.


4️⃣ Directory Navigation

CommandWhat it doespwdShow current directorylsList filesls -laList all + permissionscd dirGo into dircd ..Up one levelcd ~Home directorycd -Previous directory


5️⃣ File & Directory Operations

Create / remove

touch file.txt

mkdir dir

mkdir -p a/b/c

rm file.txt

rm -r dir

rm -rf dir # dangerous

Copy / move

cp a.txt b.txt

cp -r dir1 dir2

mv old new


6️⃣ Viewing & Inspecting Files

cat file

less file # scrollable

head -20 file

tail -20 file

tail -f log.txt # live logs

Inside less:

  • q → quit

  • /text → search

  • n / N → next / prev match


7️⃣ Searching & Finding

Find files

find . -name "*.js"

Search text

grep "foo" file

grep -R "foo" .

grep -Rin "foo" . # recursive + line numbers


8️⃣ Processes & System

ps aux

top

htop # if installed

kill PID

kill -9 PID # force

Suspend → background → foreground:

Ctrl+Z

bg

fg

jobs


9️⃣ Pipes & Redirection (Core Unix Power)

SyntaxMeaning``>Overwrite file>>Append<Input2>stderr&>stdout + stderr

Examples:

ls | grep foo

command > out.txt

command 2> err.txt

command &> all.txt


🔟 Permissions & Ownership

chmod 755 file

chmod +x script.sh

chown user:group file


1️⃣1️⃣ Networking & Debugging

curl url

curl -I url

wget url

ping google.com

lsof -i :3000


1️⃣2️⃣ Environment & Shell

env

printenv

echo $PATH

export FOO=bar

source ~/.zshrc


1️⃣3️⃣ Tab Completion & Expansion

ActionShortcutAutocompleteTabShow optionsTab TabExpand glob*Brace expansion{a,b,c}

rm file{1,2,3}.txt

1️⃣4️⃣ Terminal UI shortcuts (macOS)

ActionShortcutNew tabCmd + TClose tabCmd + WSplit paneCmd + DClear screenCtrl + L


1️⃣5️⃣ Emergency / Recovery

SituationFixTerminal frozenCtrl + CMessed up terminalresetBinary garbage outputresetZombie processkill -9 PID


🔑 Top 10 to Burn into Muscle Memory

Ctrl+A   Ctrl+E   Ctrl+U   Ctrl+K   Ctrl+R
Ctrl+C   Ctrl+Z   fg       !!       Alt+.