Three cd shortcuts everyone uses
You already know cd path and cd .. from lesson 2-1. Three more moves cover 90% of real navigation:
cdwith no argument: jump straight to your home directory (/home/youon Linux), the personal directory where your stuff lives. Its nickname is~(tilde), socd ~/projectsworks from anywhere.cd -: jump back to the directory you were in before, and print it. Great for bouncing between two places.cd /: go to the root of the tree.
Code exercise · bash
Watch cd - in action: we visit /tmp, move away to /, then bounce back. cd - prints where it's taking you, and pwd confirms it.
Stop typing full names: Tab completion
In a real terminal, type the first few letters of a file, directory, or command and press Tab. The shell finishes the name for you. Press Tab twice to see all possibilities when several match. Typing cd pro + Tab is how experienced people "type" cd projects/.
Two more keys: ↑ / ↓ scroll through your command history, and Ctrl+L clears the screen. These aren't optional polish. Tab completion also prevents typos, which matters a lot once you start deleting files in unit 3.
One more history tool professionals lean on: Ctrl+R, reverse search. Press it and type any fragment of an old command; the shell searches your history backwards and shows the most recent match. Press Enter to run it, or Ctrl+R again to step to older matches. Long commands stop being retyped — they get recalled in two keystrokes.
Practice the shortcuts in a guided session (simulated, so it behaves the same on every machine). You start in /home/sam/projects.
Step 1/4: First, see where you're standing.
Quiz
You're deep inside /var/log/nginx and type `cd` with no arguments. Where do you land?
Problem
Which key do you press to make the shell auto-complete a half-typed file name?