Linux Filesystem Structure Explained

Sohail
Sohail

Table of Contents

When I started researching Linux after leaving Windows, I found the Linux filesystem structure quite perplexing, simply because I had never known anything other than the Windows file system.

With perseverance through the learning curve, the mystery was revealed, and I can now switch between Linux and Windows whenever necessary. I understand the Windows file system better now after studying the Linux filesystem.

The most significant difference between the two file systems is determining where the file system’s root begins. In Windows, the root starts with the drive letter, generally C:, which indicates it starts with the hard disc. However, in Linux, the filesystem’s root does not correlate to a physical device or location; it is a logical position of just “/”. For a visual representation, see the graphics below.

​Linux Filesystem Structure Tree

linux filesystem structure
Image Courtesy – tldp.org

​Windows File System Tree

Windows file structure

Another thing to remember is that everything in Linux is a file. Alternatively, everything is shown as a file, whereas in Windows it may be displayed as a hard drive.

In Windows, for example, the hard drive is commonly represented as C: in the file explorer, and it will even display a small symbol of the hard drive and the amount of space that is being used. In Linux, however, the hard disc is simply represented as /dev/sda, which is really just a directory, which in Linux is really just a file that points to other files.

10 Steps To Secure Linux Server + {Bonus Tips}

Linux servers are already extremely secure by default; that’s why 100% of supercomputers, most of the top 1 million servers, and top 25% of websites on the internet run on Linux. Besides having security tools in place, users should follow a few steps to further secure Linux servers.

So here are some more concrete examples. The Linux counterpart of your Windows Documents folder is /home/username/Documents, but in Windows it’s usually C:UsersUserNameDocuments. These are indeed quite similar, but the differences are clear.

So, using the above Linux file system chart, we must study what each folder in the Linux file system is for in order to gain a better understanding of how Linux works in general. It should be noted that not every folder described here or illustrated above is present in every Linux distribution, but the vast majority of them are.

  • / – this is known as “root”, the logical beginning of the Linux file system structure. Every single file path in Linux begins from root in one way or another. / contains the entirety of your operating system.
  • /bin – Pronounced “bin” (as opposed to “bine”), this is where most of your binary files are stored, typically for the Linux terminal commands and core utilities, such as cd (change directory), pwd (print working directory), mv (move), and so on.
  • /boot – This is where all the needed files for Linux to boot are kept. Many people, including myself, like to keep this folder in it’s own separate partition on the hard drive, especially when dual-booting is involved. A key thing to note is that even when /boot is stored on different partition, it is still logically located at /boot as far as Linux is concerned.
  • /dev – This is where your physical devices are mounted, such as your hard drives, USB drives, optical drives, and so on. We’ve already explored that typically, your system hard drive is mounted under /dev/sda, whereas your USB thumb drive might be mounted under /dev/sde. You may also have different partitions on your disk, so you’ll see /dev/sda1, /dev/sda2, and so on. In Windows, when you go to “My Computer” or “Computer” and you can see all of the physical devices and drives connected to your computer, this is the equivalent of /dev in Linux file structure.
  • /etc – Pronounced “et-see”, although some also prefer to spell it out, is where configuration files are stored. Configurations stored in /etc will typically affect all users on the system; whereas users can also store configuration files under their own /home folders, which will only affect that particular user.
  • /home – This is where you’ll spend the vast majority of your time because it has all of your personal data. The /home/username directory contains the Desktop, Documents, Downloads, Photos, and Videos folders. If you choose, you can keep files directly in your /home folder rather than in a sub-folder. When you open a command-line terminal in Linux, the terminal typically links to your /home/username folder, unless you’ve manually altered the default destination to something else.
  • /lib – This is the location of libraries. When installing Linux software packages, you’ll notice that additional libraries are frequently downloaded, and they almost always begin with lib-something. These are the files required for your Linux apps to function. This folder is similar to, but not exactly the same as, the Program Files folder in Windows.
    • Unlike Windows, libraries can be shared between many distinct programmes, resulting in Linux installations that are often far lighter than Windows, because in Windows, each programme requires its own library, even if it is redundant and already existing for another programme. Certainly an advantage of the Linux file system structure.
  • /media – Another place where external devices such as optical drives and USB drives can be mounted. This varies between different Linux distros.
  • /mnt – This is basically a placeholder folder used for mounting other folders or drives. Typically this is used for Network locations, but you could really use it for anything you want. I used to use it as the mount point for my media server’s hard drive (/mnt/server).
  • /opt – Optional software for your system that is not already managed by your distro’s package manager. I don’t really ever find myself using this, your mileage may vary.
  • /proc – The “processes” folder where a lot of system information is represented as files (remember, everything is a file). It basically provides a way for the Linux kernel (the core of the operating system) to send and receive information from various processes running in the Linux environment.
  • /root – This is the equivalent to the /home folder specifically for the root user, also called the superuser. You really don’t want to touch anything in here unless you know what you’re doing.
  • /sbin – Similar to /bin, except that it’s dedicated to certain commands that can only be run by the root user, or the superuser.
  • /tmp – This is where temporary files are stored, and they are usually deleted upon shutdown, which saves you from having to manually delete them like is required in Windows.
  • /usr – Contains files and utilities that are shared between users.
  • /var – This is where variable data is kept, usually system logs but can also include other types of data as well.

You can do further study online and dive deeper to learn more about specific programmes and usage of each of the above-mentioned folders, but for the average everyday home user, your /home folder is usually the only one with which you’ll be directly engaging.

Easily Install WordPress on LiteSpeed Web Server

WordPress is a well-known content management system (CMS) on the Internet. Almost all large and small hosting providers offer several solutions for easily hosting WordPress, and LiteSpeed web server is one of those solutions.

If you’re troubleshooting, you may need to go into the other files, although most current Linux distributions automatically maintain these folders and require little to no user intervention.

Conclusion

To reiterate my prior assertion, the Linux file system is a logical rather than a physical system. Separate folders in the system may be on different partitions of the disc, or even on different discs entirely, but everything is still logically in the same place.

The simplest approach to absorb this concept is to just use Linux as your everyday driver, as immersion is the greatest way to learn. For this task, Ubuntu or Linux Mint are probably the best options. After a while of using the Linux file system, everything will click and you’ll grasp what’s going on.

Frequently Asked Questions

What is Linux Filesystem Hierarchy?

The Linux Filesystem Hierarchy is a standardized directory structure used by Linux systems to organize and manage files and directories. The hierarchy defines the system’s location, configuration, user, and program files.

Is Linux a Ext4 filesystem?

No, Linux is not an Ext4 filesystem. Linux is an operating system kernel, while Ext4 is a file system used by many Linux distributions.

What is the best filesystem for Linux?

There is no single “best” file system for Linux, as the best choice depends on the system’s specific use case and requirements.

Ext4 is a commonly used and well-supported file system for general-purpose desktop and server installations that provides good performance, reliability, and compatibility with most Linux distributions. It is also backwards-compatible with its predecessor, Ext3.

For high-performance servers and storage systems, XFS is a popular choice due to its scalable design, high-performance capabilities, and support for large files and volumes. It is particularly well-suited for use cases such as big data analytics and high-performance computing.

What is the difference between XFS and Ext4?

XFS and Ext4 are both popular file systems used in Linux systems, but there are some differences between them –

Scalability: XFS is designed to scale well on larger storage devices, supporting volumes up to 16 exabytes. In contrast, Ext4 is better suited for smaller storage devices.

Metadata handling: XFS uses a B+ tree to store file system metadata, allowing faster metadata lookups and more efficient space usage. Ext4, on the other hand, uses an indexed extensible hash table, which is less efficient than the B+ tree used by XFS.

Journaling: XFS uses a write-ahead log (WAL) for journaling, which separates metadata updates from data updates, allowing for better performance and faster recovery times. Ext4, on the other hand, uses a journaling mode that writes both data and metadata to the journal, which can slow down performance.

Fragmentation: XFS is less susceptible to fragmentation than Ext4, which can result in slower performance over time.
Compatibility: Ext4 is more widely supported by Linux distributions and is the default file system for many of them, while XFS is less widely used.

Overall, XFS is better suited for larger storage devices and high-performance computing, while Ext4 is better suited for general-purpose computing and is more widely supported by Linux distributions.
Linux TutorialsUncategorized