A path in a computer system is a combination of /(forward slash) or \ (backward slash) and alphanumeric characters. It uniquely identifies the file or directory location in the filesystem of an operating system.
For example –
The following example shows the path in a Linux system.
/home/lalit/ReportAug
On a Windows system, a path will look like as it is given below.
C:\home\lalit\ReportAug
A path can either be an absolute path or a relative path. In this article, we will discuss the same with the help of examples.
What is an absolute path?
An absolute path starts with / i.e. root directory. It always contains the root element and the complete directory list required to locate a file or directory on a system. OR you can say the absolute path is the complete path to a file or directory in a filesystem.
The following examples show the absolute path in a system.
Example 1:
/home/lalit/python_dir/enum.py
Example 2:
/var/log/syslog
By using the absolute path you can move or access any file or directory from anywhere in your system. For example, currently, I am at /etc/ to move to /var/log/apache2 we will use –
![]()
What is a relative path?
The relative path starts from your current working directory Suppose my current working directory is /var/www and I want to change it to /var/www/html then by using the relative path concept we can directly use –
cd html
![]()
Instead of using the complete path i.e. –
cd /var/www/html
Conclusion
I hope now you understand the concept of absolute and relative paths in a Linux system. Now if you have a query then write us in the comments below.