wEEK 4
Filesystem Navigation & Basic File Management
Why Filesystem Navigation Is the Backbone of Linux Work
Every Linux system runs on a filesystem—the structure that decides where data lives and how it’s retrieved. In IT work, this isn’t optional: sysadmins, developers, and support staff constantly navigate directories, edit configs, and track down logs. If you can’t move confidently through the filesystem, you’ll waste time, risk errors, and struggle in professional environments. Mastering these basics is the foundation for nearly every other Linux skill.
- Server maintenance: Configurations live in /etc and logs live in /var/log. If you can’t move between them quickly, you can’t fix issues or keep services running.
- Software deployment: Programs and libraries are stored in places like /usr/local/bin and /usr/lib. Knowing how to manage these paths is how you install or troubleshoot applications.
- User management: Every person has a home directory under /home. IT staff must organize, back up, or secure these folders to protect user data.
- Data analysis: Large datasets are rarely in one folder. Analysts need to locate, copy, and clean up files across the filesystem before they can even start working.
- Cloud/DevOps: In containers or cloud servers, you usually only get a terminal. Filesystem commands are the only way to navigate and manage resources.
N.A.V.I.G.A.T.E. Framework
This week we’re introducing a new mnemonic to organize everything you’ll do with the Linux filesystem. N.A.V.I.G.A.T.E. gives each big idea its own clearly labeled section, and on the course page each letter will use a distinct background color so you can spot topics at a glance and jump to what you need.
Navigate the tree
Think of the Linux filesystem like a family tree: it starts at the very top with / (the root directory) and branches down into folders and files. Follow the branches in the image below:
At the very top is
/. From there, you see branches like/bin,/etc,/usr, and/home.If you follow the
/homebranch, you’ll see a user folder namedtest. That’s where this user’s personal files live.Inside
testare two main folders:python_homeworkandstudy_guides.python_homeworkcontains two files:homework1.pyandhomework2.py.study_guidessplits into subjects:python(withtest1.txt,test2.txt) andOS(with its owntest1.txt,test2.txt).
Meanwhile, on the
/usr/binbranch, you can see command programs likels,vi, andman.
Every file can be described by the “path” you take down the tree. For example:
Starting at
/→home→test→python_homework→homework1.pygives the full path/home/test/python_homework/homework1.py.If you’re already sitting in
/home/test, you can take a shortcut and use the relative path:python_homework/homework1.py.
Absolute & relative paths
Once you see the filesystem as a tree, the next question is: how do we describe the location of a file?
In Linux, this is done with paths. A path is just the set of directions you follow down the tree to reach a file or folder. There are a few special rules and shortcuts that make paths easier to use:
| Path Type | What It Means | Example | IT Relevance |
|---|---|---|---|
| Absolute | Starts from the root / and spells out the full route. | /usr/bin/python3 | Used in scripts and automation for reliability. |
| Relative | Starts from where you are now in the tree. | ../images/logo.png | Used in projects where code moves between systems. |
| Home (~) | Shortcut to your home directory. | ~/projects | Lets users jump quickly to their workspace. |
Absolute paths are like street addresses — they work everywhere. Relative paths are like saying “turn left from here” — shorter, but only meaningful if you know where you’re standing.
View Contents
Now that you know how to navigate the filesystem tree, the next skill is to look inside files. Imagine walking through the branches of our tree — when you reach a leaf like homework1.py or test1.txt, you don’t always want to open a heavy text editor just to see what’s inside. Linux gives us lightweight commands to peek at file contents quickly.
| Command | What It Does | Example using the tree diagram introduced in the “Navigate the tree” section | Why Use It |
|---|---|---|---|
| cat | Prints the whole file to the screen. | cat homework1.py (from /home/test/python_homework) | Quick for small files, like short homework scripts. |
| less | Opens the file in a scrollable viewer (press q to quit). | less test1.txt (from /home/test/study_guides/python) | Useful for longer notes or logs. |
| head | Shows the first 10 lines. | head test2.txt | Good for checking file headers or the start of data. |
| tail | Shows the last 10 lines. | tail test2.txt | Handy for viewing recent log entries or results. |
| wc | Counts lines, words, and characters. | wc test1.txt | Helpful to get a quick size check. |
Navigate the tree
I — Inodes & Links (Intro)
So far we’ve been walking the filesystem tree: moving between branches (directories) and looking at leaves (files). But here’s something important: in Linux, a file is not just its name on the tree. The real file lives in something called an inode — like a little record card that stores everything about the file: its size, owner, permissions, and where the data blocks are on disk. The name you see in the directory is just a label that points to that inode.
This design lets Linux do some clever things: one file can have multiple labels (hard links), and you can also create shortcuts (symbolic links) that point to files elsewhere. You’ve actually seen this idea before in everyday life: a symlink is like a desktop shortcut to a deep folder, saving you from clicking through 10 levels every time. On professional Linux systems, admins rely on the same trick — for example, the command
pythonmay just be a symlink that points topython3.12. And over the long run, knowing that a file’s name and its data are separate helps prevent mistakes: deleting a name (rm hw1_link.py) doesn’t necessarily erase the file itself if another link to it still exists.
Key Concepts:
| Concept | Meaning | Why It Matters |
|---|---|---|
| Inode | A unique record on disk that stores metadata: size, type, owner, permissions, and where the file’s data blocks are. | Prevents confusion between name vs. actual file data. |
| Hard Link | A second name pointing to the same inode. | Multiple “labels” for the same file; delete one, the file still exists until all links are gone. |
| Symbolic Link (symlink) | A shortcut that points to another path. | Lets you reference files across directories (like desktop shortcuts in Windows). |
Commands to Know:
- Show inode numbers for files: ls -i
- Create a hard link: ln homework1.py hw1_link.py
- Create a symbolic (soft) link: ln -s /home/test/python_homework/homework2.py hw2_symlink.py
Step 1: Seeing Inodes
Try to imagine that every file in the tree diagram has a hidden number behind it — that number is its inode.
To reveal these numbers, we use: ls -i
If you ran this inside /home/test/python_homework, you might see:
131072 homework1.py
131073 homework2.py
Here 131072 and 131073 are the inode numbers. They prove each file has its own record card on disk.
Step 2: Hard Links (Multiple Labels to the Same File)
Suppose you want homework1.py to also appear as hw1_link.py in the same folder, without making a copy. That’s a hard link:
Command:
ln homework1.py hw1_link.py
Now both homework1.py and hw1_link.py point to the same inode number. Delete one, and the file still exists under the other name.
It’s like writing two labels for the same binder — no matter which label you grab, you’re still opening the same binder.
Step 3: Symbolic Links (Shortcuts)
What if you want quick access to homework2.py, but from a different folder (say, inside study_guides)? That’s where symbolic links (symlinks) come in.
Command:
ln -s /home/test/python_homework/homework2.py hw2_symlink.py
This creates a new file called hw2_symlink.py which is really just a pointer to the original.
Unlike hard links, if you delete the original, the symlink breaks (because it was only pointing to the path, not the inode).
Think of a symlink as the “shortcut” icon you’ve seen on desktops in Windows or Mac.
G – Get Organized
So far, we’ve explored the tree and inspected files. Now it’s time to talk about organizing the filesystem: creating new branches, copying or moving files, and cleaning up what you don’t need.
Some of these commands you’ve already met in earlier weeks — but here we’ll place them into the bigger picture of file management as a whole.
Think of it like setting up binders for classes: you buy a new binder (
mkdir), put in blank pages (touch), make a photocopy of notes (cp), shift a sheet to the right tab (mv), and recycle old material (rm,rmdir).
Key Concepts:
| Command | What It Does | Example on Diagram | Why It Matters |
|---|---|---|---|
| mkdir | Make a new directory (branch). | mkdir projects inside /home/test | Start a new folder for assignments. |
| touch | Create an empty file or update its timestamp. | touch notes.txt in study_guides | Begin a new note file. |
| cp | Copy files or directories. | cp homework1.py homework1_backup.py | Keep a backup before editing. |
| mv | Move or rename files. | mv test1.txt test1_final.txt | Rename or reorganize files. |
| rm | Remove files. | rm test2.txt | Delete a file you don’t need. |
| rmdir | Remove empty directories. | rmdir old_notes | Clean up empty folders. |
A - Advanced selection
So far, you’ve been working with files one at a time. But real directories often contain dozens or even hundreds of files. Typing each name individually would be slow and error-prone. That’s where wildcards come in — special characters that let you select groups of files at once.
Imagine standing in the
study_guides/pythonbranch of the tree. Instead of listing bothtest1.txtandtest2.txtseparately, you can simply say: “all files that end with.txt.” Linux understands this through the*wildcard.
Key Concepts:
| Wildcard | How to Read It | Example in Context | What It Does |
|---|---|---|---|
* | “Anything, zero or more characters” | ls *.txt | Matches all text files like test1.txt and test2.txt. |
? | “Exactly one character” | ls homework?.py | Matches homework1.py and homework2.py but not homework10.py. |
[ ] | “Pick from this set of characters” | ls test[12].txt | Matches test1.txt and test2.txt. |
{ } | “Choose from these names” | cp {notes.txt,plan.txt} backup/ | Copies both notes.txt and plan.txt at once. |
Notice how each pattern saves keystrokes and avoids errors. Instead of typing multiple filenames one by one, you describe a rule, and the shell expands it into the list of files for you.
*means “anything, zero or more characters.” Example:ls *.txtwill list every text file in a directory.?means “exactly one character.” Example:ls homework?.pymatcheshomework1.pyandhomework2.pybut nothomework10.py.
Example:[ ]lets you pick from a set of characters.ls test[12].txtmatches onlytest1.txtandtest2.txt.{ }lets you spell out multiple names at once. Example:cp {notes.txt,plan.txt} backup/copies both files together.
T – Track Location
Once you start moving around the tree, the next challenge is: how do you know where you are right now?
Linux gives you simple commands to keep track of your location — think of them as your GPS inside the filesystem.
| Command | What It Tells You | Example Use | Why It Matters |
|---|---|---|---|
pwd | Prints your current location in the tree. | /etc/nginx/sites-enabled | Prevents mistakes when editing configs. |
cd | Moves you to a different branch. | cd /var/log | Lets engineers jump into logs quickly. |
. | Refers to “here.” | ./deploy.sh | Runs a script in the current folder. |
.. | Refers to “up one level.” | cd .. | Saves time when navigating deep folders. |
~ | Always means “home.” | cd ~ | Quick return to your safe workspace. |
These commands keep you oriented. Before making changes on a server, professionals always confirm their location — a simple pwd can prevent deleting or editing the wrong files.
E – Evaluate Space
Once you start storing files in the filesystem, the next question is: how do we measure how much space they use?
In Linux, this is done with a few commands that report size, usage, and available storage. These tools help you understand not just where files are, but how much room they take up.
| Command | What It Shows | Example Use | Why It Matters |
|---|---|---|---|
ls -lh | Lists files with human-readable sizes. | Shows 2.1K instead of 2140. | Helps quickly compare file sizes in a folder. |
du -sh | Disk usage of a directory. | du -sh /home/test/study_guides | Lets admins check which folders are taking the most space. |
du -sh * | Usage of everything in the current folder. | Breaks down size by subdirectory. | Helps identify which subfolders are growing too large. |
df -h | Free space on mounted filesystems. | Shows capacity of /, /home, etc. | Crucial for monitoring storage before it fills up. |
Being able to check disk usage is critical in IT work. Logs, backups, and user files can silently grow until the system runs out of space — and when that happens, services may crash or refuse to start. A quick du or df is often the first step in troubleshooting storage issues.