Absolute Path Vs Relative Path In Linux


Absolute Path Vs Relative Path In Linux:



Absolute Path: An absolute path is defined as 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.

example:
/home/user/Document/srv.txt
/root/data/dev.jpg
/var/log/messages

All are absolute Path.


Absolute and relative path


Relative Path: Relative path is defined as path related to the present working directory(pwd). Suppose I am located in /home/user1 and I want to change directory to /home/user1/Documents. I can use relative path concept to change directory to Documents.

example:
here are two examples for changing directory, 1st by using relative path, 2nd by using absolute path.

$ pwd
/home/user1
$cd Documents/  (using relative path)
$pwd
/home/user1/Documents

or

$ pwd
/home/user1
$cd /home/user1/Documents/  (using absolute path)

$ pwd
/home/user1/Documents
  



ls command in Linux                                                       Linux-booting-process


No comments: