facebook youtube pinterest twitter reddit whatsapp instagram

Understanding the Linux Filesystem

Understanding the filesystem is important if you want to know how data is stored and retrieved, but really, the term might be somewhat confusing in Linux, as it means two different things.

A filesystem can be the default directory structure (which is the structure and logic rules used to manage the groups of data and their names), and it can be the actual filesystem we choose when formatting a volume (ext4, XFS, JFS, and the likes), which is outside the scope of this guide.

Have you ever noticed a slash (/) when entering a directory? The slash is considered the beginning of the file system, and sub-directories branch out from there. This is like going into a big building with many rooms, you start from a door, which leads you into the other rooms (think subdirectory).

Let's take the /home directory, for example, this directory exists at the root level of the filesystem, which is why we have the slash depicting the beginning.

Let's assume your home directory is /home/your-username, this means the directory your-username is inside the directory home, and thus the home directory is the beginning of the filesystem.

Use the ls command against the forward-slash to see how the filesystem is structured:

ls -la /

This would show you the listing of the root directory, which is the directory that is at the top of the directory hierarchy and that contains all other directories and files on the system. You'll see the home directory, var, usr, and others.

The directory structure you see is the default directory and is part of the Filesystem Hierarchy Standard (FHS), which is a set of guidelines that defines how the directory structure is laid out. This specification defines the names of the directories, where they are located, and what they are used for. This is why you see a similar structure across Linux distros.

If you are adding a volume to your server, you format that volume and then mount (attach) the volume to a directory on the filesystem, this can be included anywhere in the filesystem e.g the /mnt or your chosen path.

Here is a pdf that explains the structure in-depth and what they are used for Filesystem Hierarchy Standard (FHS) PDF

The below table outline the most used directories and their purpose.

Directory Used for
/ The beginning of the filesystem, sub-directories branch out from there.
/home The user home directories, each time a new user is created, a directory in the name of the user is created within the home directory which contains other personal user directories.
/root The home directory for root, it doesn't have a directory underneath /home and should never be confused with ‘/
/media Temporary mount directory is created for removable devices e.g, media/cdrom, flash drives
/mnt For volumes that are intended to stay mounted for a while
/opt Additional software packages e.g third party application
/bin Essential user binaries (ls, cp, and so on)
/proc Virtual filesystem for OS-level components
/usr/bin A majority of user commands
/etc Application’s configuration files, startup, shutdown, start, stop script for every individual program.
/var The contents of this file is expected to grow. This directory contains log, lock, spool, mail, and temp files.
/tmp System’s Temporary Directory, Accessible by users and root. Stores temporary files for user and system, till next boot.
/boot Holds important files during the boot-up process, including Linux Kernel.

There are more, but these are the main ones, the take away is that the filesystem is the structure and logic rules used to manage the groups of data and their names

Related Post(s)

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll

  • Access A Web Page In GNU/Linux Using (Links) [Web Browser in Text Mode]

    Links is a text-mode World Wide Web (WWW) browses that can be used to view a web page either via a local (file://) or remote ((http:// or ftp://) URLs. To get started with Links, install it using the

  • Synchronize File With Cloud Storage Using [Rclone] In (GNU/Linux)

    Rclone is an open-source command-line program to sync files and directories to and from different cloud storage providers. It preserves timestamps, and if you are transferring from local to cloud, it

  • Creating Command Aliases in GNU/Linux (Command Shortcuts)

    As time goes on, you'll need to be super productive with the way you use commands in GNU/Linux, and one example is utilizing alias. Using alias allows you to create an additional equivalent name for