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.
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND