You may already know a little bit about Linux, but you may not know exactly how your data is being handled under the hood. Because if you’re like a lot of other Linux users, you just take for granted these sorts of things.
But your Linux file system isn’t so carefree, so, today that’s exactly what we will be talking about – the Linux File System.
Table of Contents
What is Linux File System?
Linux file system is the collection of data and/or files stored in a computer’s hard disk or storage, your computer relies on this file system to ascertain the location and positioning of files in your storage, were it not there, the files would act as if they are invisible, obviously causing many problems.
There are actually many different file systems that exist for Linux, if you’re wondering which one you should use, we will provide a comprehensive list of the file systems that are supported by Linux.
What are the Linux File System Types?
Upon installation, Linux offers various file systems like the ones below that you can select from:
We’ll delve into each one of these Linux File Systems and give a brief description.
Ext: “ext” is an acronym that stands for “extended file system” and was created in 1992 and is the very first file system designed specifically for Linux.
Its functionality was designed partly based on the UNIX file system. The purpose of its creation originally was to innovate beyond the file system used before it (the MINIX file system) and overcome its limitations.
As this file system is about 30 years old at the time this article was written, many Linux distros no longer support it, so it is not really used anymore.
Ext2: also referred to as “second extended system”. Created in 1993, ext2 was designed to be the successor of the original extension system for Linux.
It innovated in areas such as storage capacity, and general performance. This file system notably allows for up to 2 TB of data. Like ext, this file system is very old, so it really should just be avoided.
Ext3: ext3, or third extended system, created in 2001, surpasses ext2 in that it is a journaling file system. A journaling file system is a system that records in a separate log changes and updates to files and data before such actions have been completed.
This means that if for some reason, the computer or hard disk(s) crash or experience some kind of power failure, this separate log containing the changes made before the crash can be used to access that stored data, thus repairing and restoring the files upon reboot.
Nowadays, there are so many better options to choose from that there’s hardly any reason to use this extended file system anymore either.
Ext4: ext4, standing for “fourth extended system”, was created in 2006. Because this file system overcomes numerous limitations that the third extended system had, it is both widely used, and the default file system that most Linux distros use.
While it may not be the most cutting edge, it is absolutely reliable and stable – which is really valuable in Linux.
Thus, if you aren’t particularly keen on racking your brain between the different pros and cons of all the many file systems you can choose from, we definitely recommend you just go with this one.
JFS: The file system JFS was created by IBM in 1990 and the name JFS is an acronym standing for Journaling File System, as we’ve already covered this concept with the number 3 file system in this article, you should already be quite familiar with what exactly this means.
It’s easy to recover data after a power failure and quite reliable. What’s more is it uses less CPU power than the other file systems.
XFS: xfs, an acronym that stands for “Extent File System”, was created by Silicon Graphics and originally made for their OS “IRIX”, but was later given to Linux.
Created in 1990, XFS is a 64-bit high performance journaling file system. It’s particularly noteworthy for how incredibly well it works with very large files. Though contrarily, not especially the
best with smaller files.
Btrfs: btrfs, which is yet another acronym standing for B Tree File System, created by Oracle in 2009. It is regarded as a rival file system to ext4, though it’s consensus that overall ext4 is the better file system, as it transfers data faster and offers more stability but although this is the case, that does not mean btrfs isn’t worth looking into.
There are a couple things that are unique and advantageous about btrfs. And in general it has excellent performance.
If you couldn’t tell already from the comparisons made in our list, ext4 is and is regarded as the best Linux File System.
What file system does my system use?
If you’re wondering which file system your distro has by default or simply just which one you have currently, you can define that for yourself using some pretty nifty commands in your terminal.
There are multiple ways that you can do this, but we’ll show you the easiest one down below:
Short for “disk free”, df is a command used to display the free disk space in Linux and other similar operating systems. It is also used to understand and ascertain the file systems that are mounted.
Now, you may have noticed that I mentioned that this command can be used to define the file system mounted, but when you run the “df” command yourself, there is no mention of any types of file systems. (shown below)
Well, that is where this interesting little option comes in: open your terminal and execute this command:
$ df -T
This is a variation of the
df command. It will display the file system type along with other currently irrelevant information. (shown below)
As you can see, in the second column under “Type” the file system type is defined. You should now be able to ascertain which file system you currently have mounted on your Linux distro.
What is Top Level in Linux?
/ is the top level directory of a Linux system. The name “top level” means the “root”, thus it is the root directory of the system. Though it is separate from “/root directory”, so you shouldn’t confuse the two.
All other directories stem from this top level directory like a pyramid. This concept is not unique to Linux, as the same thing can be observed in other Operating Systems such as a very interesting one you may have heard of called Windows. Windows has partitions such as C: and D:.
In Linux, these directories in the so-called “pyramid” exist in a hierarchy with a specific structure. This can be observed in your terminal by using the command:
$ cd /
, and then displaying the directories and files while in the top level directory. (shown below)
Most distros have the same structure, and the differences between some of them being only minuscule. Now that you know what the top level directory is, let’s take a comprehensive dive into what the rest of these directories are and what you can do with them.
What Are the Linux File System Directories?
/bin – essential utilities
The directory contains the core system programs and important utilities. For example, commonly used and well known commands such as “cat” are located in “/bin”.
The reason for this is that if these utilities are not stored in this directory, there is no certainty that the system will have access to them if there isn’t a file system mounted.
There is the directory /sbin that is very similar to /bin, as it contains core system administration binaries (programs).
/boot – Boot for a Boot
Contains files that are required in order for the system to be booted. For example, BIOS, which stands for Basic Input/Output System.
The BIOS is responsible for executing the Master Boot Record (MBR) boot loader.
It checks the integrity of the hard disk(s) of the system before launching the MBR. /boot also contains Linux kernels and many other files in addition to BIOS.
Though, these files’ configuration files are not stored in /boot, rather they are stored in /etc, along with the many other various config files.
/dev – Devices or Files
Linux displays connected devices as files and the /dev directory contains these files. Though, the thing is, as you can see by the title, these are not “actual” files, they just appear as files. /dev is also where physical drives can be mounted.
/etc – Configuration files
As we discussed before, the configuration files of BIOS and other similar files can be found in /etc. You can edit these configuration files in a text editor as you see fit.
Basically, every single kind of configuration file is located in /etc, including but not limited to system configuration files.
/home – Home Folder Containment
There’s a home folder for every user on your system and each one is contained together in the /home directory. These folders are created using the name of your user name.
For example, your user name is joe, so your home folder would be located in /home/joe.
These home folders contain your user data files and configuration files that are specific to the user, which is also the one of the only types of configuration files that are stored elsewhere besides /etc as we explained above.
If one wants to modify other files on a system, they must become the root user, as each user only has write permissions for their own home folder.
/lib – Libraries for Programs
Each program or binary uses specific libraries to function and the /lib directory is where these libraries can be located.
/media – Mounted Media
Contains subdirectories where your physical media devices are mounted. For example, a CD, if inserted into your system, you can access its contents through its directory that is created in the /media directory upon insertion.
/mnt – Temporary Mounts
This directory is used for mounting temporary file systems. If you are using a file system for a very specific purpose and for a relatively brief period of time, you would probably mount it in /mnt. Though you can mount it anywhere on the system if you so chose.
/opt – Optional Packages
The /opt directory contains a set of subdirectories where optional software packages are located and managed by the package manager.
/proc – Kernel and Process Pseudo Files
The /proc directory is another interesting case of a directory that contains these “fake” files, very similarly to the /dev directory that we discussed earlier in this list. These files are special files that are actually, and interestingly, system and process information.
/root – Root User Directory
As we’ve discussed before, every user has his own home directory. This is the home directory of the root user. The root user’s home directory is located at /root.
Which is noteworthy because it is, unlike the rest of the users’ home directories, not located in /home. Like we’ve said above, in an earlier section of this article, /root is different from the root directory “/”, and this fact should be committed to memory if possible.
/sbin – System Administration Programs
The /sbin directory is similar to the /bin directory in that it contains essential programs. But it differs with the addition that it is intended to be used by the root user.
/tmp – Temporary Files
The /tmp directory is used to store temporary files that are deleted when the system is restarted. Utilities such as tmpwatch can be used to delete these temporary files in the /tmp directory.
/usr – User Shared Read-Only Data
The /usr directory is used to contain applications and files that are used and shared by and between users.
/var – Variable Data
The /var directory is used like the /usr directory, only instead of being read-only, it is writable. This directory contains system logs and other various variable data.
And with that, we conclude this topic. You should now have a pretty solid idea about what a Linux File System is and how to use it. Hope you learned something and thanks for reading!
Mokhtar is the founder of LikeGeeks.com. He works as a Linux system administrator since 2010. He is responsible for maintaining, securing, and troubleshooting Linux servers for multiple clients around the world. He loves writing shell and Python scripts to automate his work.