When specifying a directory to change to, you can use either absolute or relative path names. The absolute or full path starts from the system root /, and the relative path starts from your current directory.
By default, when you log into your Linux system, your current working directory is set to your home directory. Assuming that the Downloads directory exists in your home directory, you can navigate to it by using the relative path to the directory:
$ cd Downloads
You can also navigate to the same directory by using its absolute path:
$ cd /home/username/Downloads
In short, if the path starts with a slash (/), it is the absolute path to the directory
Linux: Absolute Path
$ cd /usr/lib$ cd /usr/lib pwd
See this path (linux#1/usr/lib), when you give PWD, it gives a full path from the root level. This is called absolute or full path.
Think of the absolute pathname as being the complete mailing address for a package that the postal service will deliver to your next-door neighbor.
Linux: Relative Path
$ cd usr$ /user cd lib$ /usr/lib pwd$ linux#1/usr/lib ==> Going step by step and achieving.
$ linux#1/usr/lib cd ../../ ==> This is the method of going back step by step.
$ linux#1 ==> This is root level directory
You are currently in the lib directory. So relative path nothing but complete information of all the mother directories.
Here, for lib, the usr is the mother directory.
In simple terms, it is a step-by-step way and to reach your target directory.
- Best AI tools for Software Engineers - November 4, 2024
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024