Absloute path vs relative path in LinuxUnix

Tutorials Shared by the Internet Community

Advertisements


Absloute path vs relative path in LinuxUnix

One of this blog follower asked us that

Statistics

  • Total Hits - 32813

  • Total Votes - 111 votes

  • Vote Up - 51 votes

  • Vote Down - 60 votes

  • Domain - www.linuxnix.com

  • Category - Linux/Administration

  • Submitted By - Surendra Anne

  • Submitted on - 2013-09-17 13:21:52

Description

What is an absolute path?<br />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.<br /><br />Some examples of absolute path:<br /><br /><br />/var/ftp/pub<br />/etc/samba.smb.conf<br />/boot/grub/grub.conf<br /> <br /><br />If you see all these paths started from / directory which is a root directory for every Linux/Unix machines.<br /><br />What is the relative path?<br />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<br /><br />changing directory to /var/log/kernel by using relative path concept.<br /><br />pwd<br />/var/log<br />cd kernel<br />Note: If you observe there is no / before kernel which indicates it's a relative directory to present working directory.<br /><br />Changing directory to /var/log/kernel using absolute path concept.<br /><br /><br />cd /var/log/kernel<br />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.    More detail...


Broken  |   Tweet  |   Facebook  |     |   Save  |   Liked  |   Down

Advertisements