Navigating the Command Line
Basic Directory Navigation
cd [directory]– Change to a specific directorycd ..– Move up one directorycd ~– Go to the home directorycd -– Switch to the previous directorypwd– Print the current directory path
Listing Files and Directories
ls– List files and directoriesls -l– Long format listing (permissions, size, etc.)ls -a– Include hidden files (those starting with a dot)ls -lh– Human-readable file sizes
Path Shortcuts and Auto-Completion
~– Home directory (e.g.,cd ~/Documents).– Current directory..– Parent directoryTab– Auto-complete filenames and directories
Moving the Cursor Within a Command
Ctrl + A– Move to the beginning of the lineCtrl + E– Move to the end of the lineAlt + B– Move back one wordAlt + F– Move forward one wordCtrl + U– Cut everything before the cursorCtrl + K– Cut everything after the cursorCtrl + W– Cut the word before the cursorCtrl + Y– Paste (yank) the last cut textCtrl + L– Clear the terminal screen
Command History Navigation
↑ / ↓– Scroll through command historyCtrl + R– Reverse search through command historyhistory– Show full command history!n– Re-run command number n from history!!– Repeat the last command
Quick Directory Jumps
cd /– Jump to the root directorycd ../../– Move up two directoriescd ~/Desktop– Go directly to the Desktop