Saturday, May 25, 2024
HomeTutorialsEverything You Need To Know About the Linux File System

Everything You Need To Know About the Linux File System

Files and their manipulation lie at the center of modern computing. Even one of the core principles of all Unix-like systems is to describe everything on the system as files. It holds for virtually all Linux systems. From directories to devices, your Linux distro treats everything on your system as files. Now, systems also need to incorporate a means of storing and managing these files. This is where Linux file systems come in play. Since Linux supports numerous file systems and implements various operations for them, we feel it necessary to provide our readers some knowledge on how file systems work in Linux.

Fundamentals of Linux File System

The Linux filesystem is responsible for storing your system data and managing them. A filesystem can be defined as the mechanism behind data storing and retrieval. Filesystems are usually comprised of several layers, including a logical layer that provides user interaction, APIs for different file operations, and such.

You might’ve noticed that your entire Linux installation resolves around the / point. It is called the root of the file system and is essentially the starting point of your system. It contains several directories, most bearing some historical significance. We’ll discuss the filesystem hierarchy of Linux and other Unix’s later in this guide.

Linux check file system

You can connect additional components to this filesystem hierarchy by mounting them to a mount point. Once mounted, users can traverse new filesystems using this point. We’ll show you how to do this in the following sections. Now, how does the system keep track of these filesystems? In short, it uses pre-defined partition tables to determine the inodes(starting points), boundaries, names, and other information to do this.

When defining partition tables using Linux partition managers, you might’ve noticed that there’re multiple types of filesystem. Some common examples are NTFS, FAT, and EXT. Linux supports a wide range of filesystem types, as you will see later.

Discovering the Linux File System Structure

The Linux filesystem bears significant resemblance to the original Unix filesystem. Although modern computing innovations have aid in the increase in newer trends, the filesystem hierarchy remains almost the same due to its historical significance. We have outlined this hierarchy using appropriate examples in this section. We’re assuming you’re familiar with the command-line interpreter, aka the Linux shells.

By default, the user is presented with the /home/USER directory upon each login. You can confirm this by typing pwd in the terminal. We’ll be using tree, one of the de-facto utilities for visualizing directory hierarchies in Linux. You can get this in Ubuntu by issuing sudo apt install tree.

tree command

If you run tree in your current directory, chances are you’ll find yourself in a complex, cryptic structure. It happens because tree traverses each element in this location (i.e. Pictures, Documents, Downloads, etc) recursively and creates the final structure combining them. However, you can add the -L flag to specify the depth of this command.

$ tree -L 1

Running this command will give you a straightforward tree-like structure consisting of only the first level components of your starting point. You can increase this value for getting a more transparent, robust visualization. You can use the cd command to change locations inside your filesystem. Now, we’ve discussed earlier that everything in Linux is a file. So, a directory must be a file. Indeed it is.

Directories are just special files that contain the name of other files (aka its child elements). New Linux installations come with some in-built directories. We’ll be discussing them below. It will help you understand your system much better.

First, go to the root of your system using cd / and run ls. This will show you all of these default directories. Continue reading to find out their purpose.

Linux file system structure


It contains the binaries, aka executables of the various programs installed in your machine. In many systems, this doesn’t exist as a real directory but serves as a symlink to the /usr/bin directory.


All essential files required for the system startup are located here. You should not experiment with the contents of this directory unless you know what you’re doing. Else, you might corrupt the system itself and disrupt functionality.


The /dev directory contains the device files of your system. These are the file representations of your USB drives, hard-disk drives, Webcam, and so on.


Historically, the /etc directory was used for keeping various miscellaneous files. Today, however, it is a standard convention to store the system-wide configuration files in this directory. Information like your username/password, network credentials, mount-point of partitions is stored here.


This is the personal directory of the user. It can house multiple sub-directories based on the number of users in your machine. Say you’re user “maniac”, then you’ll be allocated the directory /home/maniac. When logged in, you’ll be presented with the /home/maniac directory inside your terminal. It is also denoted as :~$ in the Bash shell.


System libraries are located here. These are the snippets of code used by your applications to perform some task. Their example includes code snippets that draw windows or send files.


This directory is the mount-point of plug and play devices such as external storage. It is a relatively newer addition to the Linux file system.


The old and grumpy Unix admins used this directory to mount on-demand devices or partitions manually. Although used infrequently, it remains in the Linux filesystem due to its historical importance.


Stands for optional and meant to hold optional system files. Admins often use it to host third-party applications that they installed from source.


It hosts the process files, kernel modules, and similar dynamic data. You should not interfere with this else you may render your system obsolete.


Like /home but for the superuser of the system. It is the directory you’ll be presented with when you switch to the root account.


This is used for holding temporary data used by Linux system processes. Don’t mess here unless you know what you’re up for.


Like /bin but holds only system essential binaries. Various everyday used utilities like ls, cd, cp, etc are located here. Do not manipulate them.


A ‘use it for all kind’ location where various information is stored. They can include binaries, libraries, icons, manuals, and so on.


The server directory. It contains the source files of web apps and houses other communication protocols.


Another virtual directory, such as /dev. It contains sensitive information and shouldn’t be experimented unless the user knows what he’s up to.


It is used for holding temporary values that will be deleted during system reboot.


The original purpose of this directory was to host all variable files. Nowadays, it contains several sub-directories for storing things like logs, caches, and such.

There might be some additional directories in your root. It is usually subject to the specific Linux distribution and can vary across systems.

Inspecting the Linux File System Hierarchy

You can quickly move around your filesystem hierarchy using standard command-line tools. We’ve compiled a list of some of the most used Linux terminal commands for this purpose. Head over there if you’re finding it hard to keep up with the next section.

So, after firing up your terminal, you’re at the /home/USER location, pointed by the :~$ sign. You can move around to a new location using the cd (change directory) command like cd /etc. Use the tree command as below to generate a simple visualization structure of your current directory, as shown below.

$ tree -L 1

directory structure with tree

You can view the type of a file using the ls -l command. The first section of its output denotes what kinds of files you’re dealing with. For example, let’s say your current directory contains a sub-directory called Pictures and a text file called test. Issue the ls -l command in this directory and search for the line that contains information about these two elements.

You’ll see that the line containing the Pictures folder starts with d, as in directory. Meanwhile, the starting element of the line for test should be , denoting regular files. Other files like devices and sockets are represented similarly. Special files are denoted using c, sockets using s, pipes with p, block devices with b, and symbolic links with l.

listing files and directories

Another robust command that can be used for determining the type of a file is the file command itself. For the above example, running the command file Pictures would yield the result ‘directory’. Additionally, file test should yield something like ASCII text, denoting a simple text file.


You can also use the mount command for attaching a filesystem at a specific location in your hierarchy. The following command mounts the /dev/sdb device to /home/USER/devices.

$ sudo mount /dev/sdb /home/USER/devices

The user can now access the contents of this device from the selected location. To find the name of a block device, you can use the lsblk command. Similarly, lspci can be used for detecting PCI devices, lsusb to list USBs, and lsdev to list all devices.

Understanding File Types and Permissions

As mentioned already, there’re several file types in the Linux file system. Each has its own purpose, but we’ll mostly deal with regular files and directories. Regular files include everyday files such as source codes, executables, documents, music, and such. Directories are simple files that hold the name of other files. Meanwhile, special files are low-level system components like pipes and sockets. Usually, these are dealt with by the Linux kernel.

Now, permissions are a whole different concept and are extremely important for Linux users. You need to understand them clearly if you want to excel in your system administration skills. Linux, like other Unix’s, uses file permissions for determining how much privilege a user has over a file.

basic file permissions

Permissions make sure users can only access or modify those contents of the system that they’re allowed to. It is the most crucial aspect behind the security of your Linux system. Since Linux file permissions are an extremely important topic on their own, we’ll talk about them in detail in a later guide. For today, we’ll stick to the basics.

We’ve earlier used the ls -l command for determining filetypes. We determined it by merely looking at the first character of the starting column. Now, this is the column that dictates the permissions. Run ls -l again, but on a specific file/directory.

view permissions

The first section of the output should contain three fields separated by the symbol. The first character denotes the filetype. It will be for regular files, as we’ve told earlier. The next portion should contain one or more characters from the set {r, w, x}. For example, if it is rw, then the user has read(r) and write(w) access to it. If it is (rwx), the user has read, write, and execute(x) permissions.

So if this section denotes the access control of the user, then why are there two more similar sections? They are the permissions of the group and other users. Since Unix is a multi-user system, the filesystem was designed for facilitating the concurrent use of the same system by different users. Every user had their own pair of login and password, which they could use to access a system. The permissions simply define how much control a specific user has over some content.

You can modify the permissions of some contents using the chmod, and chown commands. They will be demonstrated in a complimentary guide.

An Overview of Different Linux File System Types

There’s multiple file system type in Linux-based operating systems. Common Linux file system types are ext3, ext4, zfs, FAT, XFS, and Btrfs. There’re undoubtedly many more to this list, and we’ll give a concise overview of them in short. Finding the right file system type usually depends on the users’ requirements. We advise starting Linux users to stick with the ext4 journaling file system.

Since there’re multiple types of Linux filesystems, we think it’s essential to have some knowledge on them. Here, we’re introducing 10 widely used file system type in Linux.

1. EXT filesystems

The ext(Extended File System) is designed especially for Linux and has 4 versions to date. They are ext, ext2, ext3, and ext4. Most modern distros do not provide support for ext and ext2 anymore. The ext3 version implemented journaling, a feature that prevents data corruption in case of accidental power failures. It has seen a relative decline in use since the ext4 version was released. Ext4 is the default file system type in most recent distros.

2. BtrFS

The “B-Tree File System” is an innovative file system developed by Oracle. It offers some astounding features absent in standard Linux file system types. Some of them include the ability to take snapshots on the go, drive pooling capabilities, online defragmentation, and transparent compression methods. Many people pronounce BtrFS as “Better FS” and considers it to be the next big file system type in Linux servers and personal workstations.

3. ReiserFS

ReiserFS is another journal-based file system that can be used for general-purpose computing. It is supported on Linux and sports an open source GNU GPL license. ReiserFS gained quite a following in its early years due to some of the features that were relatively new at that time. Among them included the ability to resize volumes from online, tail packing for reducing internal fragmentation, and metadata-only journaling. The development of ReiserFS has stalled due to its lead developer serving jail time.

4. ZFS

ZFS is a robust file system and volume manager developed by Sun Microsystems and is currently maintained by Oracle. It is an extremely powerful filesystem that supports massive storages, efficient compression techniques, modern RAID models, data deduplication, and many more features. ZFS is available in most Linux and BSD distributions alongside Mac OS, and FUSE. Ubuntu users can discover more about ZFS here.

5. XFS

XFS is an Ext4-like file system developed by Silicon Graphics and is available in Linux since 2001. It offers many features found in the standard ext4 filesystem but limits some of its capabilities. XFS utilizes a technique called delayed allocation for detecting file fragmentations more effectively. So, it’s suitable for setting Linux NAS and SAN storages. We found it to work better with large files but quite slower when dealing with a large amount of smaller files.

6. JFS

JFS is an acronym for ‘Journaled File System’, a Linux file system developed by IBM. It is known for its limited usage of CPU resources and provides significantly better performance for both large files and collections of multiple smaller files. Moreover, it allows system admins to resize their partitions dynamically. This feature, however, only supports enlarging, not shrinking.


HAMMER is an extremely robust file type developed for the DragonFly BSD version. It is a high-availability filesystem that supports only 64 bit systems. Hammer uses B+ trees to implement its functionalities, which include the ability to take unlimited NFS-exportable snapshots, history retention, checksums, and master-multi slave operations, among others. It also supports the on-demand deduplication of data and transparent compressions.

8. FAT

FAT or File Allocation Table is a class of filesystem known for their flexibility, and robust feature set. Some popular FAT filesystems include FAT 16, FAT32, exFAT, and vFAT. They are one of the most widely used filesystems due to their incorporation in older Windows machines. Linux supports a broad set of common FAT filesystems known for their high performance.


NTFS (New Technology File System) is another common file system type for many users. It is the default filesystem in modern Windows machines and is supported by Linux and other BSD systems. NTFS implements several techniques to increase its performance and is a journaled file system. It supports alternate data streams, various compression methods, resizing, sparse files, and many more features.

10. cramfs

The compressed ROM file system, aka cramfs, is one of the most widely used filesystem type in embedded systems. It’s only a read-only filesystem that allows the system to read images without the need to decompress them first. This is the reason why many Linux distros use it for initrd images and installation images.

There are many more file system types in Linux. Moreover, it allows users to attach multiple types of partitions in the filesystem structure. It is, indeed, a widespread practice. One special type of Linux file system is the swap. It’s actually not a filesystem, but a technique used for implementing virtual memory.

Checking File System Type in Linux

Since Linux allows users to use more than one type of filesystem at the same time, it’s often necessary to check the file system type before conducting file operations. We’ll outline some conventional methods to determine the file system type of a partition from the command line.

1. Identifying File System Type Using the df Command

You can determine the file system type in Linux using the below df command. Check out our Linux df Command Examples to understand the df command in detail.

$ df -T /

It would yield the file system type of root (/) under the output column Type.

2. Identifying File System Type Using the fsck Command

The fsck(File System Check) command can be used for determining the file system type of a partition. The -N flag is used for disabling error checks.

$ fsck -N /

This command should output the filesystem type and its block id.

checking Linux file system types

3. Identifying File System Type Using the lsblk Command

The lsblk command is used for displaying the block devices in a Linux machine. You can add the -f flag for telling lsblk to show the file system type.

$ lsblk -f

It will print out all the block devices alongside their type, mount point, and availability.

4. Identifying File System Type Using the mount Command

As discussed earlier, mount is used for attaching a device or partition to a selected location in your filesystem. You can also use it with grep to determine the file type of currently mounted Linux file systems.

$ mount | grep "^/dev"

It will show all the mounted partitions with their type.

5. Identifying File System Type Using the blkid Command

The blkid command is used for printing out the properties of block devices. It also displays the file system type, as shown by the below example.

$ blkid /dev/sda9

It contains additional information. You can use the Linux cut command to extract the specific information.

$ blkid /dev/sda9 | cut -d ' ' -f 3

6. Identifying File System Type Using the file Command

The file command prints out information regarding files and directories. Adding the -sL option to file enables it to determine the file system type also.

$ sudo file -sL /dev/sda9

It will print out the file system type of the partition /dev/sda9.

7. Identifying File System Type Using the fstab File

The fstab file contains the information used by your system for determining a file system’s type. You can use it to get the type of filesystem, as shown below.

$ cat /etc/fstab

This command will print out the file system type of your partitions alongside other information.

8. Identifying File System Type Using the parted Command

The parted command is one of the most useful ways of determining filesystem types in Linux. You can use it, as shown below.

$ sudo parted -l

This command should print all the partitions alongside their Linux file system type and other information. Use this method when you need to determine the type of all filesystems in your system.

check file system type in Linux

9. Identifying File System Type Using the inxi Command

Another useful command that allows users to find out the filesystem type is inxi. You can use the following command to discover the file system type of all partitions.

$ inxi -p

It will print all devices alongside their type information.

10. Identifying File System Type Using the mtab File

You can also grep the mtab file to get the type information for mounted filesystems. The below command shows you how to do this.

$ cat /etc/mtab | grep "/dev/sd*"

It will print out the type of information of currently mounted devices.

Ending Thoughts

Linux file system covers numerous aspects of your favorite Linux distribution. From a software engineering point of view, we discussed how Linux structures its filesystems and dictated various commands to traverse this hierarchy effectively. The file system type in Linux denotes the logical entity of a particular file system. We’ve outlined ten widely used Linux file system types and then showed you how to determine this from the terminal. Although it’s very hard to encompass the file system in a single guide, our editors have tried their best to do the impossible. Leave us a comment if you’re facing any confusion or has further questions.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.


  1. This is the single best guide on Linux filesystem on the internet. Very much detailed and practical. Thanks guys great job

  2. Thank you for this post. This is just what I need, a well written description of the linux file system.

Comments are closed.

You May Like It!

Trending Now