Classic SysAdmin: Absolute Path vs Relative Path in Linux/Unix
The Linux Foundation | 28 May 2022
This is a classic article from the Linux.com archives. For more great SysAdmin tips and techniques check out our free intro to Linux course.
What’s the difference between absolute and relative path?
To understand this we have to know what is a path in Linux.
What Is A Path?
A path is a unique location to a file or a folder in a file system of an OS. A path to a file is a combination of / and alpha-numeric characters.
What Is An Absolute Path?
An absolute path is defined as the specifying the location of a file or directory from the root directory(/). In other words we can say absolute path is a complete path from start of actual filesystem from / directory.
Some examples of absolute path:
/var/ftp/pub /etc/samba.smb.conf /boot/grub/grub.conf
If you see all these paths started from / directory which is a root directory for every Linux/Unix machines.
What Is The Relative Path?
Relative path is defined as path related to the present working directory(pwd). Suppose I am located in /var/log and I want to change directory to /var/log/kernel. I can use relative path concept to change directory to kernel
changing directory to /var/log/kernel by using relative path concept.
pwd/var/logcd kernel
Note: If you observe there is no / before kernel which indicates it’s a relative directory to present working directory.
Changing directory to /var/log/kernel using absolute path concept.
cd /var/log/kernel
Note: We can use an absolute path from any location where as if you want to use relative path we should be present in a directory where we are going to specify relative to that present working directory.
Similar Articles
Browse Categories
Cloud Computing Compliance and Security Open Source Projects 2024 LF Research Linux How-To Blog Open Source Ecosystem and Governance Diversity & Inclusion Research Data, AI, and Analytics Newsletter linux blog Training and Certification Linux Cross Technology software development Cloud Native Computing Foundation cybersecurity Announcements Decentralized Technology Legal OpenSearch Sustainability and Green Initiatives cloud native generative AI industries lf events Finance and Business Technology Networking and Edge cncf AI/ML Emerging Technology Health and Public Sector Interoperability Kubernetes Topic: Security Web Application & Development amazon web services aws community tools confidential computing challenges decentralized AI decentralized computing eBPF funding innovation investment japan spotlight kernel learning lg blog license compliance open standards openssf ospo research survey skills development state of open source tech talent transformation