The Linux file system can be confusing and overwhelming at first, var? bin? etc? wtf? but with a bit of time, you'll discover a system that gives control over your computer. Understanding the Linux file system is essential for anyone wanting to navigate, manage, and work within the Linux environment.
In this blog, I've tried to cover the working of the Linux File System and a few other important files in a very simple manner, I hope you like it.
The Root (/) Directory
All of your disk partitions and physical hard drives exist inside the root directory. Everything starts at the top which is the root directory (/). This directory serves as the starting point for the entire system structure.
Here you will find folders or directories like bin, boot, dev, cdrom, home, etc.
/bin
(Binaries)
/bin
stands for binaries, bin contains the very basic programs or user executable files, and commands such as ls, cp, chmod, and even sudo exist here.
/bin
contains commands that can be used by all users, i.e. used by both the system's administrator and its users. /bin
can also contain commands the user has manually scripted.
/boot
(Bootloader)
⚠️ This is not a directory you want to play around with ⚠️
As the name suggests, /boot
contains everything your system needs to boot, It also contains the bootloader and kernel configuration files (except configuration files not needed at boot time).
You're most likely using Grub as your bootloader, you will also find the Grub configuration file here, BUT DO NOT EDIT IT!
⚠️ This is not a directory you want to play around with ⚠️
/dev
(Devices)
I used to think /dev
stands for development or developer, but in reality, it stands for devices.
This directory contains the device files for all devices attached to your computer.
In Linux, everything is a file, for example, your SSD/HDD also exists here, its /dev/sda
, partitions on this disk are called /dev/sda1
, /dev/sda2
, and so on...
You will also find devices like your mouse or your keyboard here!
/etc
(Etcetra)
/etc
stands for et cetera, this directory contains system-wide or host-specific system configuration files, if you change something here, that will affect every user.
For example, configurations like NetworkManager.conf
exist inside /etc/NetworkManager
as shown below.
/home
(Home)
Each user on a Linux system has their own dedicated home directory, for example, my system only contains one user so I only have one directory inside my home directory.
Inside /home/username
users can store files, documents, downloads, etc.
/root
(Root)
This directory is not the root filesystem (/).
This directory is similar to the /home
directory but for the root user, basically for the system administrator account on Linux.
/lib
(Libraries)
The /lib
directory contains those shared libraries that are required by system binaries and other applications, i.e. by /bin
and /sbin
.
/lib
contains 32-bit libraries, while /lib64
contains 64-bit libraries.
/media
(Media)
This directory is the mounting point for all removable media, for example, a USB stick. Modern file managers like Thunar will automatically mount your USB drives to this directory.
/mnt
(Mount)
This directory is used for mounting the removable media temporarily. If you have to manually mount the drives, we use this directory to mount them. before accessing their contents.
/opt
(Optional)
As the name suggests, this directory contains optional add-on software packages that are not part of the core system. It allows separate installation of third-party software in a structured manner.
/sbin
(System Binaries)
The /sbin
directory contains essential system binaries that are used for system administration and maintenance tasks. These tasks can potentially impact the system's stability and configuration.
Some binaries include configuring network interfaces (ifconfig
), performing disk management tasks (fdisk
), and managing system processes (systemd
).
/var
(Variables)
This directory contains variable data files that are expected to change in size, one common example can be logs, this directory also contains cache data, spool, and application data.
/proc
(Processes)
This directory contains the visual filesystem that gives us access to information about the processes running on our system. This includes kernel settings, running processes, and other system information.
/tmp
(Temporary)
This directory is used for temporary files that will be cleared upon a reboot, these files are generally created by applications during their runtime.
Conclusion
I hope this article provided you with a brief understanding of the Linux file system structure. Navigating through these directories is key to troubleshooting problems, managing your system, and for everyday usage.
Every directory serves a purpose. As you continue with your journey with Linux, take the time to dive deeper into these directories, the more you explore the more confident you will become. Good Luck and Thanks for Reading!