Cyber 101
Operating Systems
Networking Fundamentals
4. Immersive Labs

2.2.4 The Linux file system (video + text)

In this topic, we’ll look at the file system and structure Linux uses.

This lesson includes a video lesson, a text lesson.

Video Lesson

Text Lesson

To store data on a Linux system, we use files, and files are organized into directories or folders as they are on other operating systems. These files and directories make up the file system. In order to organise files consistently on Linux systems, most distributions follow the Filesystem Hierarchy Standard, or FHS.

Linux File System Directory Architecture – The Sage Diary

This standard makes it possible for us to switch between distributions easily and to use unfamiliar distributions without having to spend a lot of time looking in different places on different systems for files we need. Though if you’re coming to Linux from another operating system, it can take awhile to get used to how files are organized.

In the Linux file system, everything starts with the file system root, which is represented by a single slash. On a Linux system, there’s only one file system root. Even if we plug in other storage devices, those become part of the overall file system and aren’t represented as separate file systems, like we might be used to seeing on a Windows system with a C and D and other drives. You can think of the file system root kind of like the my computer level on a Windows system rather than the C drive.

Using a desktop based file browser, we’ll see other disks listed as we might expect on other operating systems. Even though they’re mounted or made available within the root file system, usually under the mnt directory or inside of a directory called media. From the root, we move deeper into the file system, and at the first level, there are a variety of directories each with a specific purpose.

Some of the important directories defined by the FHS include the home directory where each user’s personal files are stored, and bin, sbin, and usr where programs of different types are kept. Again, there’s also mnt, or media, which are used for mounting or attaching other file systems, like you’d find on network shares and other disks. And how those are used will vary based on which distribution you’re using.

The etc directory is where system wide configuration files are stored. var is where changeable or variable system information is kept. This is where we’ll find system logs and logs for other software. Some directories defined by the Filesystem Hierarchy Standard aren’t real directories at all. The dev, proc, and sys directories are created by the kernel to represent hardware available on the system, including all the systems hardware, processes that run programs, settings in the kernel, and so on.

While the layout of the files and directories is called the file system, the term file system is also used to refer to different strategies or data structures for storing and representing file data and file metadata. Those are things like ext4, btrfs, ZFS, XFS, and so on. For most users, it’s not something they’ll have to think about too much, but some administrators and developers make their entire career working with and administering file systems and storage.