Linux Absolute and Relative Path

The concept of the absolute and relative path is very simple. The names “relative path” and “absolute path” give us little understanding of the concept we are learning here. The absolute path is the path that starts from the root directory of the Linux system; that is, “/” is the first character in the path. In the case of a relative path, you do not need to start the path with the slash. Instead, your location will be searched with respect to the current directory.

To understand the above concept better, we have taken some examples of changing the directory with the help of the “cd” command.

First, we have tried the absolute path. We changed the directory to /home/tutorialandexample/Desktop from the current directory.

Linux Absolute And Relative Path

Second, we have tried the relative path. We changed the directory to Desktop from the current directory.

Linux Absolute And Relative Path

Then, we tried the absolute path without the forward-slash and got an error. Because, without the slash, the path is assumed as relative and did not find the correct directory.

Linux Absolute And Relative Path

The only case when absolute and relative paths are the same thing is the root directory. You can go to the root directory and type the path without a slash or with a slash. Both things are going to work.

Linux Absolute And Relative Path