CLI Guide

⌨️ Keyboard Shortcuts

Master these shortcuts to work faster in the terminal

Ctrl + A

Jump to Start

Moves your cursor to the beginning of the line. Perfect when you need to fix something at the start of a long command.

Ctrl + E

Jump to End

Moves your cursor to the end of the line. Useful after using arrow keys to navigate through history.

Ctrl + U

Clear Line (Before)

Deletes everything from cursor to the beginning. Quick way to start over without backspacing.

Ctrl + K

Clear Line (After)

Deletes everything from cursor to the end. Handy when you want to keep the start but change the rest.

Ctrl + W

Delete Word

Removes the word before the cursor. Much faster than holding backspace.

Ctrl + L

Clear Screen

Same as typing clear. Gives you a fresh, clean terminal window.

Ctrl + C

Cancel Command

Stops the current running command. Essential when something is stuck or taking too long.

Ctrl + D

Exit Terminal

Closes the terminal session. Same as typing exit.

Command History

Browse through previously used commands. Press up to find that long command you typed earlier.

Tab

Auto-complete

Completes file names, folder names, and commands. Type a few letters and press Tab to save time.

⚠️ Common Mistakes to Avoid

Learn from these common beginner errors

🗑️

Be Careful with rm

The rm command permanently deletes files. There's no trash bin or undo.

$ rm -rf / # ❌ NEVER DO THIS - Deletes everything!

Tip: Always double-check the file name before pressing Enter. Use ls first to verify.

📁

Check Your Location

Running commands in the wrong directory is a common mistake.

$ pwd # Always check where you are first

Tip: Use pwd before running important commands.

🔒

Don't Overuse sudo

Running commands as administrator (sudo) can be dangerous if you're not sure what the command does.

$ sudo rm important-file # ❌ Bypasses safety checks

Tip: Only use sudo when you understand the command and really need it.

💡 Pro Tips

Level up your command line skills

Use Tab Completion

Instead of typing full file names, type the first few letters and press Tab. The terminal will auto-complete it for you.

$ cd Doc[Tab] $ cd Documents/

Search Command History

Press Ctrl + R and start typing to search through your command history. Much faster than pressing up arrow 50 times.

(reverse-i-search)`git': git commit -m "fix bug"

Create Aliases for Common Commands

Make shortcuts for commands you use often. Add these to your .bashrc or .zshrc file:

alias ll='ls -la' alias gs='git status' alias ..='cd ..'

Use && to Chain Commands

Run multiple commands in sequence. The next command only runs if the previous one succeeds.

$ mkdir new-project && cd new-project && git init

Read the Error Messages

When something goes wrong, the terminal tells you why. Read the error message carefully—it usually explains the problem.

$ cd nonexistent-folder cd: no such file or directory: nonexistent-folder

Use history Command

See all your recent commands with history. You can even re-run a specific command by number.

$ history 1 cd Documents 2 ls -la 3 git status $ !2 # Runs command #2 (ls -la)

🖥️ Platform Differences

Important differences between operating systems

🍎 Mac / Linux

  • Uses / for paths (e.g., /Users/name)
  • Home directory: ~ or /Users/name
  • Terminal app: Terminal, iTerm2
  • Shell: Usually bash or zsh
  • ls command works by default

🪟 Windows

  • Uses \ for paths (e.g., C:\Users\name)
  • Home directory: %USERPROFILE%
  • Terminal app: Command Prompt, PowerShell, Windows Terminal
  • Shell: CMD or PowerShell
  • Use dir instead of ls (or install Git Bash)

💡 Recommendation for Windows Users

Install Git Bash or use WSL (Windows Subsystem for Linux) to get a Unix-like terminal experience. This makes following tutorials much easier since most guides use Mac/Linux commands.

Want to learn more?

Check out the basics page to master fundamental commands.

← Back to Basics