Differences between Absolute path and Relative path in Linux
A path defines a resource's location on the Linux file system. Linux file system contains files and directories. Files save the data. Directories organize the files systematically. The root (/) directory is the main directory. All directories and files reside under it. A file or directory's location starting from this directory is known as the path of that file or directory. Based on how it is written, a path can be categorized into two types: absolute and relative.
Absolute Path
The absolute path starts from the root (/) directory and goes up to the object (file or directory). It contains the names of all directories in the middle. It includes the parent directory's name on the left.
Let us take an example.
A user creates a directory in his home directory. To write the absolute path of this directory, we start writing the path from the root directory. A forward slash represents the root directory. After / (root directory), we write the directory's name, which contains the user's home directory.
A path also uses a forward slash as the path separator. It creates confusion. In an absolute path, the leftmost forward slash represents the root directory. After that, all forward slashes are path separators.
The default file system creates a home directory to save all home directories. By default, Linux assigns a home directory to each user account in this directory. It uses the username as the name of the home directory. For example, if the username is sanjay, the name of the home directory will also be sanjay.
If we write the home directory's name just after the root directory, we get the absolute path of the home directory.
If we write the user's home directory's name just after the absolute path of the home directory, we get the absolute path of the user's home directory.
Following the same track, if we write the directory or file's name created in the user's home directory just after the absolute path of the user's home directory, we get the absolute path of that directory or file.
In our example, the absolute path of the test directory will be /root/home/sanjay/test.

Key points
- The first forward slash (/) in the absolute path represents the root directory. Besides this, all slashes in the path represent the directory separator.
- Besides the last name, all names in the absolute path belong to directories. The last name can belong to a file or directory.
- The absolute path contains directory names in the hierarchy. It includes the parent directory's name on the left side.
- The absolute path does not change when we change the current directory.
- To know the absolute path of the current directory, we can use the command pwd.
Relative path
A relative path starts from the current directory and goes up to the object. It depends on the current directory. When we change the directory, it also changes. Like the absolute path, it also includes the parent directory's name on the left side. Unlike the absolute path, all forward slashes in the relative path are the directory separators.
Single dot (.) and double dots (..) in Linux
In Linux, every directory contains a single dot and double dots. When we create a directory, the shell automatically creates these dots. By default, these dots are hidden and do not show in the output of the ls command. To view these dots, use the -a option with the ls command. The single dot refers to the directory itself, and the double dots refer to its parent directory or the directory that contains it. Shell allows us to access the current and parent directories using single and double dots, respectively. Using these dots, we can build the relative path of any file or directory from the current directory.
The following figure shows the relative path of the directories used in the previous example.

Let's take another example. Suppose a user wants to view a file in the hierarchy of the two directories above from his current directory. To access this file, he can use the following relative path.
../../file
Similarly, he can use the following path if the file is available in the three directories above in the hierarchy.
../../../file
A relative path of a directory or file above in the hierarchy always starts with a single dot followed by a forward slash as ./. The ./ represents the current directory.
Unlike the current and parent directories, the child directory does not use a symbol. If the file or directory is available below in the hierarchy, we must use the actual names of child directories in the path.
For example, if a file named abc is available in the directory named dir1, and the directory dir1 is available in the current directory, the relative path of this file will be the following.
./dir1/abc
Shell uses the current directory as the default directory to execute a command. Because of this, if the target object is available in the child directory of the current directory, we can omit the leading ./ from the relative path. For example, we can access the above file using the following path.
dir1/abc
In some situations, skipping the current directory from the relative path makes it ambiguous. In that case, we can use the full path, including the current directory. For example, we must use the full relative path to run a script from the current directory.
Let's take a few more examples.
Create a directory named dir1 and a file named abc in it. Create a simple script named simple.sh in the current directory and run the following commands.
| Command | Description | Used path |
| cat ./dir1/abc | Print the abc file's contents. | Relative (Include the current directory) |
| cat dir1/abc | Print the abc file's contents. | Relative (Skip the current directory) |
| cd ./dir1 | Change the current directory to dir1 | Relative |
| cd .. | Change the current directory to the parent directory | Relative |
| cd /home/sanjay/dir1 | Change the current directory to dir1 | Absolute |
| cp ./dir1/abc | Copy the abc file in the current directory | Relative |
| ./simple.sh | Run the script from the current directory | Relative |

Conclusion
Understanding the differences between absolute and relative path names in Linux is crucial for effective navigation and file management within the file system. Absolute paths provide the complete path from the root directory, ensuring you can locate a file or directory regardless of your current location in the file hierarchy. This path remains consistent and is always valid as long as the directory structure does not change. On the other hand, relative paths are flexible and depend on your present working directory. They are convenient for quick access to files and directories within a familiar context.
Author Laxmi Goswami Updated on 2026-01-21