Python Basic Filesystem Navigation & Directory Hierarchy
The Unix Filesystem Hierarchy Standard (FHS) starts from the single root directory `/`. Navigating the tree requires mastering absolute paths (starting with `/`), relative paths (starting from current directory), `.` (current directory), `..` (parent directory), and `~` (user home directory).
"The Unix filesystem is an upside-down tree with its single root (/) at the very top. Absolute paths are like GPS coordinates (accurate from anywhere), while relative paths are like walking directions from your current street corner."
Deep Dive: How It Works
Root Directory (/): The single unified root of all mounted drives and virtual filesystems.
Key FHS Directories: /bin (essential binaries), /etc (system configurations), /home (user profiles), /var (logs and dynamic data), /tmp (ephemeral temp files).
Special Path Symbols: `.` is current dir, `..` is parent dir, `~` expands to $HOME, `-` toggles back to previous directory ($OLDPWD).
Syntax Blueprint
pwd # Print working directory cd /var/log # Absolute path navigation cd ../etc # Relative path navigation cd - # Jump to previous directory cd ~ # Jump to home directory
Navigate the filesystem using absolute paths starting with / or relative paths using . and ..
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Confusing / (root directory) with /root (the home directory of the root superuser).Why it happens: Both contain the word root.
How to fix: Remember that / is the base of the entire system; /root is just the admin profile folder.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Navigate Directories and Print Path
Create a directory `/tmp/my_test_dir` using `mkdir -p /tmp/my_test_dir`.
Change directory into it with `cd /tmp/my_test_dir`.
Print the current working directory with `pwd`.
Clean up by removing the directory with `rm -rf /tmp/my_test_dir`.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.