Absolute and Relative Paths in Linux: Your Guide to Navigating the File System

Release Management Professional | Transitioning to DevOps
With a proven track record in Release Management, I'm on an exciting journey to transition into the world of DevOps. I specialize in orchestrating the smooth deployment of software and applications, and I'm now gearing up to bridge the gap between development and operations.
My passion lies in optimizing release processes, automating deployments, and ensuring the efficiency of IT operations. I'm actively enhancing my skill set in DevOps practices, including cloud technologies, scripting, and CI/CD pipelines.
I'm keen to connect with professionals who share this enthusiasm and explore opportunities for mutual growth and collaboration in the DevOps domain. Let's connect and exchange insights about the evolving landscapes of Release Management and DevOps!
#ReleaseManagement #DevOps #EfficiencyOptimization
Introduction
Paths are like directions that help us navigate through the file system in Linux. Whether you're exploring the terminal, writing scripts, or managing files, understanding absolute and relative paths is key! Let's dive in
π Absolute Paths
Think of absolute paths as the full address starting from the root directory, denoted by a forward slash ("/"). They provide a complete route to a specific location in the file system. π β¨
For example:
/home/user/Documentsrepresents the Documents folder inside the user's home directory./var/log/syslogpoints to the syslog file stored in the log directory./etc/passwdleads to the password file in the etc directory./usr/bin/python3: This absolute path leads to the Python3 executable located in the/usr/bindirectory./etc/apache2/httpd.conf: Here, we have the Apache configuration file stored in the/etc/apache2directory./var/www/html/index.html: This path points to theindex.htmlfile inside the/var/www/htmldirectory, typically used for web server files.
Absolute paths always begin from the root directory, regardless of the current location. They're like GPS coordinates that pinpoint the exact location on the map! ππΊοΈ
π Relative Paths
Relative paths, on the other hand, are like directions based on the current location. They are defined relative to the directory you're currently in. πΆββοΈποΈ
For example:
If you're currently in the
/home/userdirectory, thenDocumentsrefers to the Documents folder directly within it.Similarly, if you're in the
/var/logdirectory,syslogrefers to the syslog file in that same directory.And if you're in the
/etcdirectory,passwdpoints to the password file located there.If you're currently in the
/home/userdirectory:To access the
Picturesdirectory located within it, you can simply usePictures.To go up one level and access the parent directory
/home, you can use...To navigate to a file in the
Downloadsdirectory, you can useDownloads/file.txt.
If you're in the
/var/logdirectory:To access the
auth.logfile in the same directory, you can directly useauth.log.To go back to the parent directory
/var, you can use...To reach the
syslogfile in the/var/logdirectory, you can usesyslog.
If you're in the
/etcdirectory:To access the
hostsfile in the same directory, you can usehosts.To go up one level and access the parent directory
/, you can use...To navigate to the
cron.ddirectory, you can usecron.d.
Relative paths are convenient when you're already inside a particular directory and want to navigate to another location nearby. They're like giving directions to a nearby landmark! π°πΊοΈ
Remember, relative paths don't start with a forward slash. They depend on the current working directory.
Example:
Let's say you want to make a directory structure like the one below here is the line of command you will be firing on from your terminal

[root@192 Desktop]# mkdir -p /linux/{RHCSA/{rhel7/{usr,partition},rhel8/{vdo,stats},rhel9/{security,LVM}},RHCE/{rhel7,rhel8}}
Once the above is done it is time to add the files to the RHCE director under the rhel7 and rhel8 folder
[root@192 Desktop]# touch /linux/RHCE/rhel8/ansible
[root@192 Desktop]# touch /linux/RHCE/rhel7/config
Conclusion
In conclusion, understanding the difference between absolute and relative paths in Linux is essential for navigating the file system effectively.
Absolute paths provide the complete route from the root directory, regardless of your current location. They start with a forward slash and act as fixed coordinates, pointing directly to a specific location in the file system. Think of them as a GPS system that can take you anywhere, no matter where you are.
On the other hand, relative paths are defined based on your current directory. They don't start with a forward slash and are used to navigate to locations nearby. Relative paths are like giving directions based on landmarks around you, such as going up a level or moving to a directory adjacent to your current one.
By understanding both absolute and relative paths, you can effectively navigate through the file system, access files and directories, and execute commands with ease. So, whether you're a beginner exploring Linux or an experienced user managing files and directories, knowing the difference between absolute and relative paths will undoubtedly make your Linux journey smoother.
Feel free to experiment with different paths, explore your file system, and have fun while mastering the art of navigating in Linux! If you have any further questions, don't hesitate to ask. Happy exploring! ππ




