The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

224 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE


You’ll see the prompt change to:

pi@raspberrypi:~/Desktop $

That shows you that your current working directory has changed: you were in your home
directory before, indicated by the ~ symbol, and now you’re in the Desktop subdirectory
underneath your home directory. To do that, you used the cd command – change directory.

There are four ways to go back to your home directory: try each in turn, changing back into
the Desktop subdirectory each time. The first is:

cd ..

The .. symbols are another shortcut, this time for ‘the directory above this one’, also known
as the parent directory. Because the directory above Desktop is your home directory, this
returns you there. Change back into the Desktop subdirectory, and try the second way:

cd ~

This uses the ~ symbol, and literally means ‘change into my home directory’. Unlike cd ..,
which just takes you to the parent directory of whatever directory you’re currently in, this
command works from anywhere – but there’s an easier way:

cd

Without being given the name of a directory, cd simply defaults to going back to your home
directory. The final way to get back to your home directory is to type:

cd /home/pi

This uses what is called an absolute path, which will work regardless of the current working
directory. So, like cd on its own or cd ~, this will return you to your home directory from
wherever you are; unlike the other methods, though, it needs you to know your user name.

CORRECT CASE
Raspbian’s command-line interface is case-sensitive, meaning that it
matters when commands or names have upper- and lower-case letters.
If you received a ‘no such file or directory’ message when you tried to
change directories, check that you had a capital D at the start of Desktop.
Free download pdf