When working on Linux operating systems we can observe a change compared to systems like Windows or macOS and this is due to the general structure of the system which has a large part focused on aspects such as files and processes and all this is based on the standard. file system hierarchy (FHS – Filesystem Hierarchy Standard) which is responsible for managing the structure of file systems in Linux.
That is why we can determine a series of directories in Linux where an essential part of the operating system or the user’s work is housed, the files in Linux are ordered by:
- General files which are ordinary binary or ASCII data files within which are images, documents, audio and video, etc.
- Device files which are a special type of file that allow device drivers to use their features to their fullest in Linux
- Directory files, in Linux each of the directories can be classified as files because they can be used as storage space for other items
Solvetic will explain in detail the structure used in Linux to manage the folders and thus have a more comprehensive knowledge of everything internally.
Linux Folders Structure | Linux Directory Tree
Root directory (/)
In Linux, the root directory is identified by a forward slash (/) and it is the top directory that manages the directory structure in Linux, there are the general Linux directories, subdirectories and files.We open the terminal and to access the root directory we enter /:
We list the content with “ls -l”:
There we will see details such as:
- Modification date and time
- Path where the object is hosted
/boot directory
It is without a doubt one of the key directories of Linux since the system boot files are in it, this includes the GRUB boot loader, the kernel and other files, to take into account the boot loader configuration files they are located in another location on the system.
To see the contents of the Boot directory we enter:
cd /boot/
We list the content:
ls -l
/etc directory
It is one of the most used and important directories in Linux since in it we find the system configuration files for services, scripts and third-party applications that are used, it is important to know that the user-specific configuration files are housed in the directory start of each user in particular, to see the contents of the directory etc we enter:
cd /etc
We list the content:
ls /etc/
Home Directory /home
In this directory the personal folders and files of each user created in Linux are housed, we can have access to folders such as Desktop, Documents, Downloads, Images and more, as an extra the /home directory integrates some personal configuration files that are identified with a period (.), the user will only have write access to his home folder and must use elevated permissions to modify the other system files if necessary, to see the contents of the Home directory we enter:
cd /home
Then we list the content:
ls -l /home/
Root Directory /root
This is the home directory for the root user, which is an administrative user and system administrator who has maximum permissions. To see the contents of the Root directory, enter:
sudo ls -l /root/
We enter the password to view said content:
/opt directory
This is a directory that is reserved to host complementary packages and third-party software applications which do not come by default from the official system repositories, to see the content of OPT we enter:
ls -l /opt
/dev directory
In this directory we can find the device files or special files for devices connected to the operating system and their operation is given by the input and output system calls and as such these are virtual files and not physically located on the hard drive, this directory emits output like:
- /dev/null: indicates that it is possible to send commands to destroy any file or string
- /dev/zero – includes an infinite sequence of 0
- /dev/random: holds an infinite sequence of random values
To see the contents of the Dev directory we enter:
ls /dev
/var directory
Variable files that are generated by the operating system are housed in this directory, this includes log files, caches, etc. One of the advantages is that these files are not cleaned automatically, which offers more complete administration alternatives, for see the content of Var we enter:
ls -l /var
We can see details of each object with their respective permissions and modification dates.
/bin directory
It is a directory where user binaries, executable programs and system commands that are used daily such as ls, pwd, cat, mkdir, cd, mv, cp, du, df, tar and more are included, to see the content of Bin we enter:
ls /bin/
We see in detail each command.
/sbin directory
In this directory we can access the executable files, utilities and system commands reserved for the root user or for a user with root privileges, some of these commands are reboot, mkfs, fsck, fdisk, iptables, ifconfig, ip, swapon and many more, to know the content of Sbin we enter:
ls /sbin/
/usr directory
It is a directory where we find read-only system files, there it is possible to see the libraries, user binaries, programs and utilities of the operating system, some examples of use are:
- ‘/usr/bin’: there we find basic user commands
- ‘/usr/sbin’: we will see the additional commands for the administrator
- ‘/usr/lib’: find the system libraries
- ‘/usr/share’: the documentation of all the libraries is hosted
To see the contents of the user’s directory we enter:
ls -l /usr
/proc directory
This is a virtual file system where information about the running processes is stored, it can manage the kernel parameters of the Linux kernel, this file system is created when the system starts and will be destroyed when the system is turned off, to have access to the contents of the processes directory we enter:
ls /proc/
/mnt directory
This is a directory intended to be used as a temporary mount point for storage devices such as hard drives, USB drives and CDROM drives, system administrators can use mnt to manually mount a file system, to access to the content of the mount points we enter:
ls -l /mnt/
/sys directory
This is a virtual file system where the set of virtual files that provide an interface for the Linux kernel is housed, to access the content of the virtual file system we enter the following:
ls -l /sys
We can see the permissions, user and related object.
/media directory
As its name indicates, it is a directory where the system can mount removable media such as USB drives or external drives, to see the multimedia directory we execute:
ls -l /media
/run directory
This is a temporary file system where we find volatile runtime data, these files from the /run directory must be removed during the Linux boot process, if we want to see the volatile boot data we run:
ls /run/
/tmp directory
As its name refers, it is a directory that stores temporary files and can be used to create lock files and preserve temporary data storage, the contents of the /tmp directory are deleted when the system is rebooted.
To access the temporary content we enter:
ls /tmp/
/lib directory
In this directory all the standard libraries that are required by the user binaries are located in the /bin directory, the libraries that are needed by the binaries in /usr/bin and /usr/sbin are located in the /usr/lib directory.To see the library directory we execute:
ls /lib
/srv directory
It is the services directory and in it we find specific files of the server and those related to the service, to see the services directory enter:
ls -l /srv
We can find many more files and directories in Linux with their respective function such as:
- /dev/sda – is a device file for the SATA drive (hard disk drive)
- /boot/vmlinuz: is the Linux kernel file
- /dev/hdc: is the device file for the IDE CD-Rom
- /dev/hda: is the device file for the first detected IDE HDD
- /etc/hosts.allow: is the file that indicates which hosts can connect to the local system
- /etc/hosts – is a configuration file to map system hostnames to respective IP addresses
- /dev/null: indicates that the target does not exist
- /etc/crontab: is a file that has a unique format for the purpose of scheduling or automating Linux system tasks
- /etc/fstab: is a special file where you have access to information about all available mount points as well as mount point options
- /etc/printcap – sends printer information generated by the /etc/cups/printers.conf file
- /etc/passwd: is a file where system user information such as username, UID, GID and login shell is found
- /etc/profile – find the Linux system environment and other startup scripts
We see how this structure helps us to correctly administer Linux and have a clear perspective of each file system.