The Linux File System Structure Explained
The Linux File System Structure Explained
Rosetta, 2019
Another thing to remember is that in Linux, everything is a file. Or, more accurately, everything is represented
as being a file, while in Windows it may be displayed as being a disk drive.
For example, in Windows the hard drive is typically represented as C:\ in the file explorer, and it will even
display a little icon of the hard drive and display how much space is being used. In Linux, on the other hand,
the hard drive as represented merely as /dev/sda, which is really just a folder/directory, which in Linux is really
just a file that points to other files.
So let’s take some other more practical examples. The Linux equivalent of your Documents folder in Windows
would be /home/username/Documents, whereas in Windows it’s typically C:\Users\UserName\Documents.
These are actually pretty similar, but you can see where the differences lie.
So using the above Linux file system chart, we need to explore what each folder in the Linux file system is for,
which will help us to better understand how Linux works in general. Note that not every folder listed here or
pictured above necessarily appears in every Linux distro, but most of them do.
Have you wondered why certain programs are located under /bin, or /sbin, or /usr/bin, or
/usr/sbin?
For example, less command is located under /usr/bin directory. Why not /bin, or /sbin, or
/usr/sbin? What is the different between all these directories?
In this article, let us review the Linux file system structures and understand the meaning of
individual high-level directories.
1. / – Root
Every single file and directory starts from the root directory.
Only root user has write privilege under this directory.
Contains binaries, libraries, documentation, and source-code for second level programs.
/usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under
/usr/bin. For example: at, awk, cc, less, scp
/usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin,
look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
/usr/lib contains libraries for /usr/bin and /usr/sbin
/usr/local contains users programs that you install from source. For example, when you install apache
from source, it goes under /usr/local/apache2
Contains library files that supports the binaries located under /bin and /sbin
Library filenames are either ld* or lib*.so.*
For example: ld-2.11.1.so, libncurses.so.5.7