Absolute vs Relative path in Linux

Author:
In Linux, a path is the sequence of directories that you navigate through to find a file or folder. There are two types of paths: absolute and relative.

An absolute path is a complete path that starts from the root directory (“/”) and lists all the directories you need to navigate through to reach the desired file or folder. For example, “/home/user/Documents/file.txt” is an absolute path to the “file.txt” file in the “Documents” folder of the “user” directory.

A relative path, on the other hand, is a path that is relative to your current directory. It specifies the path to a file or folder relative to your current location in the directory tree. For example, if you are in the “/home/user/” directory, the relative path to the “file.txt” file in the “Documents” folder would be “Documents/file.txt”.

To summarize, absolute paths start from the root directory and provide the complete path to a file or folder, while relative paths specify the path to a file or folder relative to your current location in the directory tree.

Leave a Reply

Your email address will not be published. Required fields are marked *