THE LINUX FILE SYSTEM – Part 1: Introduction

Most of the activities carried out by a computer user revolve around files – ranging from pictures, music, videos, documents, and the likes. And it is very important to be able to locate and mange files easily. So in this post and the next to follow w would be examining the Linux file system and the things we could do with it.


What is a file system?

The term file system (FS) refers to hierarchy of the entire files (directories too) on a computer system and how they are arranged. That is, the entire files and directories located on a single partition or disk. (A partition is a section of a hard disk that contains a single type of file system.)

It can also be used to refer to how data (including files and directories) are stored (using different processes and rules) on a computer disk (hard disk, thumb drive, floppy disk, CDROM, etc.) Every type of file system determines how data are stored and manipulate on a particular type of disk.

Arrangement of files and directory

A user mainly see the Linux file system in the sense of how the files and directories are arranged including the files and directories they also contain. You find out that almost all Linux distros have very similar file and directory structure with only minor differences. This is because they all follow the standard set out by an organization known as the File Hierarchy Standard (FHS). This standard enables “Software to predict the location of installed files and directories, and users to predict the location of installed files and directories”. It specifies guiding principles for each area of the file system, and the minimum files and directories required. Also enumerating exceptions to the principles, and specific cases where there has been historical conflict. Operating Systems (OS) that follow the standard set out by FHS are referred to as “FHS-compliant”.

On a Linux system, directories and files are identified by their names – starting from a single directory, called the root which is represented by a “/” (forward slash). This should not be confused with the “root” user – which is used to represent the administrator of a Linux system. The root as used in the case of FS connote the idea of the starting point (or you could say “source”) of the files and directories on the computer system. This root directory contains a series of subdirectories, each of which, in turn, contains further subdirectories, etc. It basically look like this;


Checking your location pwd

In a GUI environment the current location you are in the file system is displayed on the address bar in the nautilus window.


When using the Linux command line terminal it is natural to get somehow caught between the file system’s web of files and directories. There is a command that is available to determine or locate where you are on the file system. It the pwd (print working directory) command.


The above output from the pwd command shows I’m in my home directory, /home/alexander.

Changing your location – cd

Navigating the file system using the nautilus file explorer is more or less a straight forward. It is simply pointing and clicking your way around. But on the command line the cd (change directory) command is used. To leave my home directory (/home/alexander) for another directory, say “document”, I simply do;


With the cd command I can go wherever I want to, just combining it with the desired location or path. To return to a directory up one level from your current location use;

With the cd command I can go wherever I want to, just combining it with the desired location or path. To return to a directory up one level from your current location use;


READ  Assigning and removing file access permissions

cd ..


While to return to your home directory from anywhere you type;


cd ~


The “~” is called the tilde symbol.


Contents of each directories

It is important for you to know that when viewing a Linux file system the file system is contained within a single tree, regardless of how many devices are connected. In a Windows environment each file system is mounted separately – designated by different alphabets (e.g. Local Disk C:, D:, E: and so on). But in a Linux system it’s just one single tree. For instance if you connect a new file system like an external hard or flash drive to a Linux system, the drive is mounted on the existing Linux “root” directory structure.

So if you want to see the directories contained in the root directory of your system, you can use the ls (list) command.

ls /

bin cdrom etc initrd.img lost+found mnt proc run srv tmp var

boot dev home lib media opt root sbin sys usr vmlinuz

Every file, device, directory, or application is located under this one directory. Under this, we can see the beginnings of the rest of the directory structure. And each of these directories is organized to store specific types of files – more details are given below.


This directory stores many utilities of Linux. These utilities are the commands available under the OS. When you search this directory you’ll find many common commands which are needed to achieve a minimal working environment upon booting and that we have been using, like ls, pwd, and cd here. They are in the binary format, therefore, the name “bin”.


This directory contains the actual files, images, and kernels necessary to boot the system. While /bin contains basic, essential utilities, /boot contains the core components that actually allow the system to boot. If you need to modify the boot loader on your system, or if you vmlinuz would like to see the actual kernel files and initial ramdisk (initrd), you can find them here. This directory must be accessible to the system very early on.


This directory houses the files that represent devices on your system. Every hard drive, terminal device, input or output device available to the system is represented by a file here. Depending on the device, you can operate on the devices in different ways. For instance, for a device that represents a hard drive, like /dev/sda, you can mount it to the file system to access it. On the other hand, if you have a file that represents a line printer like /dev/lpr, you can write directly to it to send the information to the printer.


This is directory stores the operating system-related data, which users and the OS usually refers to from time to time. This directory is basically a configuration directory for various system-wide services. By default, this directory contains many files and subdirectories. It contains the configuration files for most of the activities on the system, regardless of their function. In cases where multiple configuration files are needed, many times an application-specific subdirectory is created to hold these files. If you are attempting to configure a service or program for the entire system, this is a great place to look.


This location contains the home directories of all of the users on the system (except for the administrative user, root). If there are more than one user for a particular system, a directory matching their username will typically be created under this directory. Hidden files and directories (represented by a starting dot) that allow for user-specific configuration of tools can also be found in this directory.


This directory contains libraries of data that are required by the /bin and /sbin directories. These files basically provide functionality to the other programs on the system. You might not be coming here often.


This is a special directory that contains files recovered by /fsck, the Linux file system repair program. If the file system is damaged and recovery is undertaken, sometimes files are found but the reference to their location is lost. In this case, the system will place them in this directory. In most cases, this directory will remain empty. If you experience corruption or any similar problems and are forced to perform recovery operations, it’s always a good idea to check this location when you are finished.


This directory is typically empty at boot. Its real purpose is simply to provide a location to mount removable media (like CDs). In a server environment, this won’t be used in most circumstances. But if your Linux operating system ever mounts a media disk and you are unsure of where it placed it, this is a safe bet.


This directory is similar to the /media directory in that it exists only to serve as a organization mount point for devices. In this case, this location is usually used to mount file systems like external hard drives, etc. This directory is often used in a VPS environment for mounting network accessible drives. If you have a file system on a remote system that you would like to mount on your server, this is a good place to do that.


This directory’s usage is rather ambiguous. It is used by some distributions, but ignored by others. Typically, it is used to store optional packages. In the Linux distribution world, this usually means packages and applications that were not installed from the repositories. For instance, if your distribution typically provides the packages through a package manager, but you installed program X from source, then this directory would be a good location for that software. Another popular option for software of this nature is in the /usr/local directory.


The /proc directory is actually more than just a regular directory. It is actually a pseudo-filesystem of its own that is mounted to that directory. The /proc filesystem does not contain real files, but is instead dynamically generated to reflect the internal state the of Linux kernel. This means that we can check and modify different information from the kernel itself in real time. For instance, you can get detailed information about the memory usage by typing cat /proc/meminfo.


This is the home directory of the administrative user (called “root”). It functions exactly like the normal home directories, but is housed here instead.


This directory is for the operating system to write temporary runtime information during the early stages of the boot process. In general, you should not have to worry about much of the information in this directory.


This directory is much like the /bin directory in that it contains programs deemed essential for using the operating system. The distinction is usually that /sbin contains commands that are available to the system administrator, while the other directory contains programs for all of the users of the system.


This directory contains information involving security enhanced Linux. This is a kernel module that is used to provide access control to the operating system. For the most part, you can ignore this.


This directory is used to contain data files for services provided by the computer. In most cases, this directory is not used too much because its functionality can be implemented elsewhere in the file system.


This is a directory that is used to store temporary files on the system. It is writable by anyone on the computer and does not persist upon reboot. This means that any files that you need just for a little bit can be put here. They will be automatically deleted once the system shuts down.


This directory is one of the largest directories on the system. It basically includes a set of folders that look similar to those in the root / directory, such as /usr/bin and /usr/lib. This location is basically used to store all non-essential programs, their documentation, libraries, and other data that is not required for the most minimal usage of the system. This is where most of the files on the system will be stored. Some important subdirectories are /usr/local, which is an alternative to the /opt directory for storing locally compiled programs. Another interesting thing to check out is the /usr/share directory, which contains documentation, configuration files, and other useful files.


This directory is supposed to contain variable data. In practice, this means it is used to contain information or directories that you expect to grow as the system is used. For example, system logs and backups are housed here. Another popular use of this directory is to store web content if you are operating a web server.

In conclusion…

As have been noted before, the details of where things are stored can vary from distro to distro. The best way of exploring the filesystem is simply to go through the various directories and try to find out what files are inside. You will begin to be able to associate different directories with different functions and be able to guess where to go for specific tasks. If you want a quick reference for what each directory is for, you can use the built-in manual pages by typing:

man hier

This will give you an overview of a typical filesystem layout and the purposes of each location.

Happy Linux’NG!




Chief Editor/Founder at FossNaija
A Linux enthusiast with a focus on enriching the Nigeria Linux experience and keeping a keen eye on Ubuntu and other Foss related developments.

Tell us what you think