Just like any other operating system, UNIX operating system keeps things tidy and ordered by storing files in a series of different directories. These directories all have standard uses, but the one we are going to pay attention to is home. Similar to the ‘My Documents’ directory on a windows system, each user has a home directory where they can store their personal files.

Home sweet home!
Having logged in using the username ‘pi’, you will first be placed into your home directory – ‘/home/pi’. We can check this by entering the pwd command (print working directory) that will display our current location.
pwd
The system will reply with a line indicating your current location in the filesystem.
/home/pi
We also get a clue about our location by looking at the first bit of the command prompt. The tilde (~) lets us know we are in our home directory.
pi@raspberrypi ~ $
Moving around
Changing directory is achieved using the cd (change directory) command. So to change into a directory on your SD card called ‘/home/pi/files’ we can just issue the command:
cd /home/pi/files
We can check this has worked using pwd, or by looking at the command prompt:
pwd
/home/pi/files
pi@raspberrypi ~/files $
Alternatively we can use the tilde abbreviation for our home directory.
cd ~/files
And again we can check our location with pwd.
/home/pi/files
Relative and absolute paths
As well as specifying the full path when referring to files or changing directories, we can use relative paths that reduce the length of command we need to execute. A single dot refers to the current directory, with a double dot referring to the parent directory.
If we first move back to our home directory using one of the following:
cd
or
cd ~
or
cd /home/pi
We can then move into the ‘files’ directory using one of the following:
cd files
or
cd ./files
or
cd ~/files
To move back to our home directory we can use
cd ..
or
cd ../
Finally, showing off we can nest these commands together making something way more complex than required at the moment, but forming a useful way of thinking about moving around directories.
To move into our files directory we can issue a command which takes us home, then into the files directory referenced from that location.
cd ~/./files
To move back again we can head up two levels into the home directory, before heading down into the pi directory again:
cd ../../pi
Summary of navigation commands
pwd |
Print the working directory |
cd |
Change directory |
. |
Current directory |
.. |
Parent directory (one up) |
~ |
Home directory |