This article explains basic commands for navigation within Linux file system. The diagram below represents (part of) a Linux file system know as Filesystem Hierarchy Standard. A line from one node to a node on its right indicates containment. For example, the student directory is contained within the home directory.

FileSystem Hierarchy Standard direcotry tree

1. When you are working within a shell terminal, you are always operating in a particular directory. To determine which directory you are in, use the pwd command:

student@linuxgym:$ pwd /usr/local/bin 
student@linuxgym:$ cd
student@linuxgym:$ pwd /home/student
student@linuxgym:$

 

2. Your home directory is the directory you are in when you first open the terminal. To go to your home directory from anywhere, just type "cd":

student@linuxgym:$ pwd
/usr/local/bin
student@linuxgym:$ cd
student@linuxgym:$ pwd
/home/student
student@linuxgym:$

3. An absolute path name is one beginning with the "/" character, which signifies the root of the file system tree. Therefore, another way of going to your home directory is:

student@linuxgym:/etc$ cd /home/student
student@linuxgym:$ pwd
/home/student
student@linuxgym:$

4. A relative path is one which starts with the name of a directory connected to the current directory. For example, if you are in the /usr directory, then typing only "cd bin" (without preceding "bin" with "/") has the following effect:

student@linuxgym:$ pwd
/usr
student@linuxgym:$ cd bin
student@linuxgym:$ pwd
/usr/bin
student@linuxgym:$

and you go to /usr/bin rather than /usr/local/bin or /bin. 5. To go to the directory containing the current working directory (also called the parent directory) type:

student@linuxgym:$ pwd
/usr/bin
student@linuxgym:$ cd ..
student@linuxgym:$ pwd
/usr
student@linuxgym:$

6. The relative pathname of the current working directory is called "." (the full stop). Therefore typing:

student@linuxgym:$ pwd
/usr/bin
student@linuxgym:$ cd .
student@linuxgym:$ pwd
/usr/bin
student@linuxgym:$

does not change the current working directory.

Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top