Linux Tutorials

The Linux File System Structure Explained

When I initially started researching Linux after leaving Windows, I found the Linux filesystem structure to be 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, and I actually feel like I understand the Windows file system better now after studying the Linux file system.

The most significant difference between the two file systems, in my opinion, 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 root of the filesystem does not correlate to a physical device or location; rather, it is a logical position of just “/”. For a visual representation, see the graphics below.

Before we continue, we’d like to tell you about Contabo. We host LinuxAndUbuntu on Contabo VPS. Check them out if you need web hosting. Prices start at $6.99 per month for an 8GB RAM and 4 Core CPU VPS.

contabo vps

​Linux File System Structure Tree

linux file 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.

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.

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.

Also Read –
Linux Mint Best Distro for New Linux users



2 comments

Sonia Pena January 9, 2021 at 5:13 am

How would you characterize Windows Server drives in Linux? Does something like this exist in Linux?

Reply
Sara Siddiqui January 30, 2022 at 3:01 am

Hi Sohail,

This was very informative for the beginner like me. The comparison that you made between windows and linux helped me understand how each folder is related to the sub folders in linux.

Would like to see more in details about linux.
Thanks for your support.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.