Path in Unix
Path in Unix
• Absolute path starts from the directory root (/) and goes up to the
actual object (file or directory). It contains the names of all directories
that come in the middle of the directory root and the actual object. In
this, name of the parent directory is written in the left.
• Suppose you are currently located in home/kt and you want to
change your directory to home/kt/abc.
• First forward slash (/) in the absolute path represents the directory root.
Besides this, all slashes in the path represent the directory separator.
• Besides the last name, all names in the absolute path belong to
directories. Last name can belong to file or directory.
• In the absolute path, directories names are written in their hierarchy
order. Parent directory’s name is written in the left side.
• Absolute path does not change when we change the current directory.
• To know to the absolute path of the current directory, we can use the
command pwd.
Relative path
• Relative path is defined as the path related to the present working
directory(pwd). It starts at your current directory and never starts
with a / .
• Relative path starts from the current directory and goes up to the
actual object. Relative path depends on the current directory.
• When we change the directory, relative path also changes. Just like
the absolute path, the name of the parent directory is written in the
left side. Unlike the absolute path, all slashes in the relative path
represent the directory separator.
Relative path also uses these dots to represent the current directory and the
parent directory respectively. With the use of these dots, we can build the
relative path of any file or directory from the current directory.
Changing directory with relative path concept :
• $pwd
• /home/kt
• $cd abc
• $pwd
• /home/kt/abc