Navigate Through the File System

The pwd (print working directory) command outputs the directory you’re currently in.

 
pi@raspberrypi ~ $ ​pwd
 
/home/pi

As you can see, your home directory (~) expands to the absolute path /home/pi. Linux distinguishes between absolute and relative paths. Absolute paths always begin with a forward slash (/) and reference the same file no matter where you are in the file system. Relative paths, on the contrary, are relative to your current position in the file system. The following example will clarify the difference between absolute and relative paths.

As you saw in the preceding section, the pi user’s home directory contains two directories named Desktop and python_games.

 
pi@raspberrypi ~ $ ​ls
 
Desktop ...

Get Raspberry Pi, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.