Linux Filesystem Structure

by Felix Kinaro About 2 min reading time

Overview

There are many ways to define a filesystem. All depend on the perspective, hence none are wrong:

Some modern filesystems like the Z filesystem and btrfs combine raid and volume management features with a traditional filesystem. This results in a versatile filesystem that allows the system administrator to efficiently manage redundancy and snapshots.

Filesystems can also be within files. For example, you can create a 1 GB file, encrypt it, and create a volume within it to store your files. You would need to enter your password every time to access the files.

Additionally you can also have a swapfile instead of a dedicated swap partition. This makes it easy to resize based on your needs.

The Filesystem Hierarchy Standard

The Filesystem Hierarchy Standard is a convention that defines the names, locations, and permissions of files and directories. We can find more about this on the Redhat documentation site.

It is maintained by the Linux Foundation.

To view the basic structure of a Linux filesystem we can use the tree command to list the structure. To install the application on Debian/Ubuntu run:

apt install tree -y

List the top-level layout:

tree -L 1 /

This will list the top-level directories starting from /. The output is a minimalistic view
Tree Command

To get the ownership and permissions we can use the ls command:

ls -l /

Using ls to view filesystem

The output includes attributes such as owner and permissions.

Creating Partitions

There are many tools we can use to create partitions.

The Man pages have detailed explanations of how each of these commands works. Run man command to view instructions.

Why a Filesystem is Necessary

Naming stored files

You need an easy way to access your files.

Tracking changes

Filesystems like btrfs allow us to create snapshots of files and volumes. Consider a scenario where you have multiple virtual machines on a server and you want to make changes that may be potentially destructive. We can create a snapshot at the filesystem level. The snapshot will diverge from the original once we make changes. If we are satisfied or disappointed with the outcome, we can delete the snapshot and revert to the previous state.

Managing access in multi-user systems

Multi-user systems like Linux rely on permissions to determine who has access to what and the actions they can perform. Linux users are classified into owner, group, and world.

Conclusion

In this guide we have explored what filesystems are and why they are necessary. We will delve further on creating partitions in the next post.

Subscribe to receive weekly articles

Your data is handled by Buttondown.