COMP 10024 – Fundamentals of UNIX (Week 3)

February 2, 2026 7:27 pm Published by

The UNIX File System, Part 2

To recap last week’s lecture, a file system’s primary job is to manage data storage on random access devices using a hierarchical structure. Today, we will move beyond just “where” files are and look at “what” they actually are.


1. Pathfinding Review

Before we dive into the guts of the system, let’s test our navigation skills. Imagine we are currently working in Bob’s home directory (/home/bob). Based on the system structure, here is how we reach specific files:

/ (Root)
├── tmp/
│   └── file_a (Target 1)
└── home/
    ├── bob (YOU ARE HERE)
    │   ├── file_a
    │   └── cars/
    │       ├── m3.jpg
    │       └── loan.xls (Target 2)
    └── alice/
        ├── file_a (Target 3)
        └── bikes/
            └── Cervelo.jpg
Target File Absolute Path Relative Path (from /home/bob)
file_a (in tmp) /tmp/file_a ../../tmp/file_a
loan.xls /home/bob/cars/loan.xls cars/loan.xls
file_a (in alice) /home/alice/file_a ../alice/file_a

2. Inside the Inode: Metadata Explained

Recall that an inode is a data structure that stores metadata—which is simply “data about data”. If you look inside an inode, you find almost everything you need to know about a file, except its name.

Field Description
File Size The total size of the file in bytes.
Owner IDs The User ID (UID) and Group ID (GID) associated with the file.
Permissions The “Mode” defining who can read, write, or execute the file.
Timestamps Records for creation, last modification, and last access.
Link Count The number of directory entries pointing to this inode.
Disk Pointers The actual addresses on the physical disk where the file’s data is stored.

3. The Hunt for the Missing Filename

If the filename isn’t in the inode, where is it? The answer is: The Directory. In UNIX, a directory is just a special type of file that acts as a simple mapping table.

For example, if you look inside the cars directory file, you would see a table like this:

File Name inode Number
m3.jpg 890
loan.xls 998

This explains how UNIX “finds” a file. It looks in the directory to find the name, grabs the associated inode number, and then goes to that inode to find the data on the disk.


4. Moving Up and Down the Tree: . and ..

To allow us to navigate “up” toward the root, every directory contains two magic entries:

  • Dot (.): Maps to the directory’s own inode.
  • Dot-Dot (..): Maps to the parent directory’s inode.

5. Hard Links vs. Symbolic Links

One of the most powerful features of UNIX is the ability to have multiple names for the same data.

Hard Links

A hard link occurs when two different filenames in a directory map to the exact same inode number.

  • Because they share an inode, they share all permissions and timestamps.
  • If you edit one, the other changes instantly because they point to the same physical data blocks.
  • This increases the “Link Count” in the inode.

Symbolic (Soft) Links

Think of these as “redirects” or Windows shortcuts.

  • A symbolic link has its own unique inode.
  • Instead of pointing to data blocks, its data blocks contain the path to the original file.
  • If the original file is deleted, the symbolic link “breaks” because the target path no longer exists.

6. New Commands for Your Toolkit

Command Action
mkdir [name] Creates a new directory.
rmdir [name] Removes an empty directory.

 

Categorised in: , ,

This post was written by amax

Comments are closed here.