The Linux Filesystem

perfectogo
4 min readAug 10, 2023

--

In this article, we will be exploring the Linux filesystem hierarchy. We will describe the directory structure and how it differs from other operating systems.

Linux Filesystem

Linux OS’s have a secure, multi-user filesystem. Its directory structure is organized to maintain a good balance between security and functionality. Directories accessible to the user are separated from directories needed by the administrator.

Linux generally follows the Filesystem Hierarchy Standard (FHS). This standard reference (developed in 1994) describes the common layout conventions used by most UNIX and UNIX variant systems. It consists of a single primary (or root) directory with multiple branching sub-directories.

Root Directory ( / )

The root directory / is the starting point for the entire Linux filesystem hierarchical tree. It is the top-most directory from which all other file systems are mounted at system boot up. All files and folders will branch from the root directory even if the data is stored in different places physically.

The root directory is owned by the root user (admin) and its permissions are tightly controlled to allow only administrators to add, remove, or modify files and folders in this directory.

Sub-Directories

By convention, Linux has several important sub-directories, each with its own specific purpose and permissions. Some of these sub-directories are accessible to anyone (i.e. /tmp) while others are only accessible to the administrator (i.e. /etc).

This table provides some details on the purpose of each of the common Linux sub-directories.

#SUB-DIRECTORY PURPOSE
/bin common binary executables used by all users
/boot files associated with boot loader
/dev attached devices (usb, cdrom, mouse, keyboard)
/etc configuration files
/home personal directories for each user account
/lib shared system libraries
/media directory for mounting removable devices (floppy drive, cdrom)
/mnt directory for mounting filesystems (nfs, smb)
/opt optional vendor add-on software
/proc virtual filesystem for system processes/resources information
/root home directory for administrator account
/run storage for runtime information
/sbin binary executables used by administrator
/srv data for server services
/sys virtual filesystem for hardware/driver information
/tmp temporary files purged on reboot
/usr utilities and read-only user data/programs
/var variable and log files

Linux versus Other Filesystems (macOS and Windows)

Coming from Windows

Windows and Linux are quite different in design. Here are some key differences: In contrast to Windows’ single-user system, Linux has a multi-user design. While Windows uses separate data drives like C:\WINDOWS and D:\DATA, Linux uses a tree-like hierarchy structure with everything branching off of the root. On Windows, program and system files are saved in the same path (C:\Program Files) and application files are kept in C:\Program Files\Application. In Linux, the program, system, and application files are all separated (i.e. /bin, /boot, /usr/bin).

Coming from macOS

Apple’s macOS owes its heritage to Unix and BSD operating systems so its core file structure is similar to Linux. Like Linux’s file structure, it too has a single primary directory with all sub-directories branching of the root (/) directory.

In fact, many of the same Linux sub-directory names can be found in macOS while other sub-directories have just had a slight name change. For example, instead of the /home sub-directory, macOS uses the sub-directory name /Users to house a user’s account and personal files.

Sub-directory similarities to Linux include:

/bin /etc /dev /usr /sbin /tmp /var

Sub-directories found in macOS but not Linux are:

/Applications /Developer /Library
/Network /System /Users /Volumes

Conclusion

The Linux filesystem isn’t so different from other filesystems we’re used to. In this article, we’ve noted the key differences that make the Linux filesystem unique. As you navigate within your own Linux environment, you will naturally gain more experience with what each directory’s purposes are!

Linux Bash Utilities

Learn about useful Linux Bash utilities!

The Linux shell language, called Bash, gives us a world of possibilities in interacting with the operating system. We also have the ability to compress files, archive, and extract them, all from the ease of the command line! We even have useful functions to look up documentation for all commands.

Note that we go through command line basics in a separate course, so if you’d like to take a look at our Learn the Command Line course first to practice basic navigation and filesystem modifications in Bash, we recommend doing so!

--

--