Introduction
As I continue my RHCSA journey with the 30-day Linux challenge, today’s focus is all about mastering paths something that might seem small but it plays a huge role in working effectively within a Linux environment.
Understanding the difference between absolute and relative paths is essential for navigating the file system with confidence, writing scripts and managing tasks precisely. So let’s simplify this with examples, tips and real-world use.
Index
🧭 What Are Paths in Linux?
A path is the address of a file or directory in the Linux filesystem. It tells the shell where a file or folder is located.
There are two types of paths:
🔹 Absolute Path
An absolute path starts from the root (/
) and shows the full directory route to the file or folder.
📦 Example:
/home/sana/documents/report.txt
This points to the exact location no matter where you are in the system.
🔹 Relative Path
A relative path starts from your current directory. It doesn’t begin with /
.
📦 Example:
documents/report.txt
This works if you are already in /home/sana
.
📝 Use .
(current directory) and ..
(parent directory) to move within paths:
cd ../downloads
📂 Practice
🔍 Check where you are:
pwd
📁 Move using absolute path:
cd /home/sana/projects
🚶 Move using relative path:
cd ../projects
🛠️ Real Time Scenario
You’re writing a shell script to copy files. If you use a relative path and the script runs from a different directory it fails. Using an absolute path ensures reliability.
✅ Pro Tip: In automation (like cron jobs), always prefer absolute paths for consistency.
🧠 Recommendations
- Practice moving around using both types of paths.
- Try writing a script using absolute paths, then modify it with relative ones.
- Combine this knowledge with
cd
,pwd
,ls
andfind
.
🚀 Quick Summary
Even the smallest habits like using the correct path can save you hours of confusion and debugging.
I'd love to hear your thoughts, insights or experiences with Linux. Feel free to share and join the conversation [ Connect with me on LinkedIn www.linkedin.com/in/techwithsana ]💜
#30dayslinuxchallenge #redhat #networking #cloudcomputing #cloudengineer #cloudarchitect #cloud #RHCSA #RHCE #RHEL #WomeninTech #Technology
Top comments (0)