Updated on January 21st, 2021 – The Linux file system comes originally from UNIX and thus follows UNIX traditions. This is why for instance it uses the forward slash instead of the back slash as in Windows. Linux also differentiates between uppercase and lowercase letters, .e.g. the file with the name tesT is different than the file named TEst and so forth. Linux however, makes no difference between a directory and a file : “In UNIX everything is a file, if it is not, then it is a process” .
Unlike Windows users, Mac users might be more familiar with Linux since Mac has evolved from UNIX (was called BSD) .
You can see above a typical diagram of a Linux file system with all of the different folders or directories. As mentioned earlier, a directory is actually a file. You will notice this if you work with the command line.
If you issue the command :
ls – l
as displayed below :
You will see the type of the file shown at the beginning of the line. For example d stands for Linux directory and – for a normal file.
Here is a list of the common file types in Linux :
- – : regular file.
- d : directory.
- c : character device file.
- b : block device file.
- s : local socket file.
- p : named pipe.
- l : symbolic link.
Now let’s go through the most important directories in linux.
1 – BIN
This folder will contain most if not all of the programs or applications of the machine. You will be able to find for instance the program dir which lists your directories and also the program echo which outputs text to the screen or to a file…
2 – BOOT
This is one of the important folders in Linux since it contains all the files the OS needs in order to boot,.i.e. This is where the boot loaders live, .e.g the file grub.conf which you find in the grub directory, the set of vmlinuz, initrd, system map and kernel related files …
The vmlinuz file (selected above) contains the current Linux kernel, which is loaded by grub before being executed. In other words, it the Linux kernel executable.
The System.map (shown above) file is used to debug crashes of the kernel. It has a list of kernel data or symbols along with the addresses these symbols are located at. Note that a symbol is just the building block of a given program: it can be a function name or a variable name. Each time the kernel compiles, a new System.map is file generated .
Read: How to speed up Linux
The initrd file (Linux initial RAM disk) : is a temporary file that contains different drivers and executables that are used to allow the root file system to be mounted. The kernel and the initrd are loaded to memory by the boot loader before starting the kernel.
The boot loader afterwards informs the kernel about the existence and whereabouts (where it is located in memory) of the initrd file. The kernel decompresses the initrd if it was compressed and mounts it as a temporary root file system. Another program called linuxrc is then started in order to carry out all the things necessary to mount the proper root file system.
The config file has a list of kernel configuration options which tell which features were compiled into the kernel and which were built as modules.
It is just a legacy mounting point for your cd-rom that is left there for compatibility reasons. It is not found in all distros though.
DEV is the folder where all your devices live. You’ll find your hardware, .e.g your keyboard, your mouse, your printer…a disk for instance would be found as /dev/sda whereas and a partition on that disk would be for example /dev/sda1. This is a folder that applications and drivers will access.
ETC directory in Linux, also called Etsy. It contains all configuration files (a configuration file a local file that controls the operation of a program) of the system or in its sub-directories.It is a good practice to backup this directory regularly as it will save a lot of re-configuration in case you re-install or lose your current installation.
Each user in Linux is assigned a specific directory that can only be accessed by them and the system administrator. This is where you store your personal files, install programs and save documents. The HOME directory in Linux contains also your personal configuration files also known as the dot files (a dot precedes the name of the file). These are usually ‘hidden’ and if you want to display them, you would have to switch on the appropriate option in your file manager or run the command ls with the -a switch in the terminal.
For example, the dotfiles like .xsession and .bashrc, the configuration files for X and Bash respectively, live in this /home directory.
7 LIB and LIB 64
In the /lib directory we can find the kernel modules and also the shared library files that are needed by the boot operation of the system. Libraries can easily be identifiable via the extension of *.so. In Windows, the equivalent would be a dynamically linked library or DLL. Note that the Kernel modules ( including the drivers) are can be found in the subfolder /lib/modules/’kernel-version’.
MEDIA directory contains sub-directories in which removable media such as cdroms and USB keys can be mounted on by the system.
Contrary to the media folder mentioned previously, the MNT directory is the folder in which you ( or the system administrator ) mount devices or filesystems manually. The operation of making a filesystem available to the OS is called mounting. Note that some distros allocate /floppy and /cdrom (.e.g. Debian) as mount points whereas Redhat for instance put them in /mnt/floppy and /mnt/cdrom
OPT directory in linux is the optional folder where usually manually installed software and add-on packages from vendors reside (.i.e not part of the original installation).
TMP is a temporary directory where files are temporarily stored by applications . If you’re writing a document in LibreOffice for example, it will regularly save a temporary copy in this folder. It is usually emptied when you reboot the system. Sometimes you might find some files that have not been purged because the system can’t delete them. This is normally not a big deal unless there are hundreds of files in which case you might want to log in as the root user in single user mode and navigate to this folder in order to manually delete them.
As one of the most important directories, /usr, contains all the user binaries along with their libraries, documentation etc.In other words, it is the “user usable programs and data” or User system resources as some people call it. Note that any application installed here is considered as non-essential for basic system operation.
‘/var’ contains variable data (like system logging files, printer spool directories, mail etc) that is expected to grow in size. For example:
– /var/crash holds information about processes that have crashed
– /var/mail Contains user mailbox files
– /var/log contains log files for both the system and other different applications.
– /var/lib contains dynamic data files/libraries.
– /var/spool spool data of applications
This is the service directory where service data is stored. In case you run a server such as a web server or FTP server you would store the files that will be accessed by external users in /srv/ ( can be used for cfengine configs , svn repositories etc ..)
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.