Installation guide

Chapter 11. Shell Prompt Basics 103
If you are currently in directory3 and you want to switch to directory1, you need to move up in
the directory tree.
Executing the command
cd directory1
while you are in directory3, will present you with an error message explaining that there is no such
directory. This is because there is no directory1 below directory3.
To move up to directory1, type:
cd /directory1
This is an example of an absolute path. It tells Linux to start at the top (/) and look down until it finds
directory1. A path is absolute if the first character is a /. Otherwise, it is a relative path.
Absolute paths will take you to any directory, from any directory. Relative paths will only take you to
directories below your current one.
Use the following exercise to test what you have learned so far regarding absolute and relative paths.
From your home directory, type the relative path:
cd ../../etc/X11
The command cd .. tells your system to go up to the directory immediately above the one in which
you are currently working. cd ../.. tells it to go up two directories.
After using the full command in the example, you should be in the directory /X11, which is where
you will find configuration files and directories related to the X Window System.
Take a look at your last cd command. You told your system to:
1. Go up one level to your login directory’s parent directory (probably /home)
2. Then go up to that directory’s parent (which is the root, or /, directory)
3. Then go down to the etc directory
4. Finally, go to the X11 directory
Conversely, using an absolute path would get you to the /etc/X11 directory more quickly. For ex-
ample:
cd /etc/X11
Note
Always make sure you know which working directory you are in before you state the relative path to
the directory or file you want to get to. You do not have to worry about your position in the file system,
though, when you state the absolute path to another directory or file. If you are not sure, type pwd.
Command Function
cd returns you to your login directory
cd ~ also returns you to your login directory