Linux Labs

First steps / Stage 5 of 15

Navigation and paths

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 8 · on a machine · 4 min

Move around and check where you are

cd changes the current directory, and with it the meaning of every relative path. Three short commands take you up, home, and back.

cd path moves the shell into a directory and prints nothing. pwd and the prompt show where you ended up.

Command Where it takes you
cd .. to the parent directory, one level up
cd home, to ~
cd - back to the directory you were in before the last cd

Two dots .. name the parent directory, and a single dot . is the current directory itself. They can sit inside a path: from /etc/nginx/sites-available, the path ../nginx.conf leads to /etc/nginx/nginx.conf.

You can only move into a directory. Given a file, cd prints the error Not a directory.

Exercise · look

Up, across, and back

You are in ~/path-lab/project. Run the three commands: a move through .., pwd, and a return with cd -.

First, predict

You are in ~/path-lab/project. Where does cd ../notes take you?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Ubuntu 24.04
Loading…