The Linux filesystem and directory structure explained ๐งโ
The Linux Directory Structure is a hierarchical organization system for Linux directories and files. This structure is defined by the Filesystem Hierarchy Standard (FHS)
However, the standard does not yet define some directories in Linux file systems.
However, the standard does not yet define some directories in Linux file systems.
If you're new to Linux or switching from Windows, the file system structure of the Linux operating system may appear strange and confusing. C: and other drive letters have been replaced by /.
๐ง / - ๐ง๐ต๐ฒ ๐ฟ๐ผ๐ผ๐ ๐ฑ๐ถ๐ฟ๐ฒ๐ฐ๐๐ผ๐ฟ๐
The root directory, represented by a forward slash (/), is at the top of the directory structure. The root directory contains the directories and files that comprise the Linux system.
The root directory, represented by a forward slash (/), is at the top of the directory structure. The root directory contains the directories and files that comprise the Linux system.
You may have seen some internet jokes that reference "rm -rf /." The rm command in Linux is used to delete files and directories.
You are simply instructing your system to delete the contents of the root directory forcefully and recursively with rm -rf /. You end up deleting everything and your Linux system because the root directory contains everything. As a result, use this command with caution.
๐ง /๐ฏ๐ถ๐ป - ๐๐ถ๐ป๐ฎ๐ฟ๐ถ๐ฒ๐
The majority, if not all, of the system's programs or applications, such as cd, cat, ls, and so on, are located in the /bin directory. The vast majority of the programs are binary in nature and are available to all Linux users.
The majority, if not all, of the system's programs or applications, such as cd, cat, ls, and so on, are located in the /bin directory. The vast majority of the programs are binary in nature and are available to all Linux users.
๐ง /๐ฏ๐ผ๐ผ๐ - ๐๐ผ๐ผ๐ ๐ณ๐ถ๐น๐ฒ๐
This is an important folder in Linux because it contains all of the files needed by the operating system to boot, such as the boot loaders, such as the file grub.conf found in the grub directory, as well as the set of vmlinuz, initrd, and kernel related files.
๐ง /๐ฑ๐ฒ๐ - ๐๐ฒ๐๐ถ๐ฐ๐ฒ ๐ณ๐ถ๐น๐ฒ๐
This is where all of your devices are stored. Your hardware, such as your keyboard, mouse, and printer, can be found here. A disk, for example, would be identified as /dev/sda, and a partition on that disk as /dev/sda1.
This is where all of your devices are stored. Your hardware, such as your keyboard, mouse, and printer, can be found here. A disk, for example, would be identified as /dev/sda, and a partition on that disk as /dev/sda1.
๐ง /๐ฒ๐๐ฐ - ๐๐ผ๐ป๐ณ๐ถ๐ด๐๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐ณ๐ถ๐น๐ฒ๐
The /etc directory contains the system's core configuration files, such as the password file, hostnames, and networking files, which are primarily used by the administrator and services.
The /etc directory contains the system's core configuration files, such as the password file, hostnames, and networking files, which are primarily used by the administrator and services.
๐ง /๐ต๐ผ๐บ๐ฒ - ๐จ๐๐ฒ๐ฟ ๐ฝ๐ฒ๐ฟ๐๐ผ๐ป๐ฎ๐น ๐ฑ๐ฎ๐๐ฎ
Each user in Linux is assigned a directory that only they and the system administrator have access to. This is where you save personal files, install programs, and save documents.
Each user in Linux is assigned a directory that only they and the system administrator have access to. This is where you save personal files, install programs, and save documents.
The HOME directory in Linux also stores your personal configuration files, also known as dot files (a dot precedes the name of the file).
These are typically 'hidden,' and in order to see them, you must enable the appropriate option in your file manager or use the terminal command ls with the -a option.
Assume you have two users named foo and bar on your Linux system. They'll each have their own home directories at /home/foo and /home/bar.
๐ง /๐น๐ถ๐ฏ - ๐ฆ๐ต๐ฎ๐ฟ๐ฒ๐ฑ ๐น๐ถ๐ฏ๐ฟ๐ฎ๐ฟ๐ถ๐ฒ๐
The /lib directory contains the kernel modules and shared library files required for the system to boot. Libraries are easily identified by the extension *.so.
The /lib directory contains the kernel modules and shared library files required for the system to boot. Libraries are easily identified by the extension *.so.
In Windows, the equivalent would be a dynamically linked library or DLL.
๐ง /๐บ๐ฒ๐ฑ๐ถ๐ฎ - ๐ ๐ผ๐๐ป๐ ๐ฝ๐ผ๐ถ๐ป๐ ๐ณ๐ผ๐ฟ ๐ฟ๐ฒ๐บ๐ผ๐๐ฎ๐ฏ๐น๐ฒ ๐บ๐ฒ๐ฑ๐ถ๐ฎ
The media directory contains subdirectories in which the system can mount removable media such as CDs and USB keys. This directory provides access to the contents of removable media.
The media directory contains subdirectories in which the system can mount removable media such as CDs and USB keys. This directory provides access to the contents of removable media.
๐ง /๐บ๐ป๐ - ๐ ๐ผ๐๐ป๐ ๐ฑ๐ถ๐ฟ๐ฒ๐ฐ๐๐ผ๐ฟ๐
Like the previously mentioned media folder, the /mnt directory is where you (or the system administrator) manually mount devices or filesystems. The process of making a filesystem available to the operating system is known as mounting.
Like the previously mentioned media folder, the /mnt directory is where you (or the system administrator) manually mount devices or filesystems. The process of making a filesystem available to the operating system is known as mounting.
๐ง /๐ผ๐ฝ๐ - ๐ข๐ฝ๐๐ถ๐ผ๐ป๐ฎ๐น ๐๐ผ๐ณ๐๐๐ฎ๐ฟ๐ฒ
The /opt directory in Linux is an optional folder that typically contains manually installed software as well as vendor add-on packages (.i.e not part of the original installation).
The /opt directory in Linux is an optional folder that typically contains manually installed software as well as vendor add-on packages (.i.e not part of the original installation).
๐ง /๐ฝ๐ฟ๐ผ๐ฐ - ๐ฃ๐ฟ๐ผ๐ฐ๐ฒ๐๐ ๐ฎ๐ป๐ฑ ๐ธ๐ฒ๐ฟ๐ป๐ฒ๐น ๐ณ๐ถ๐น๐ฒ๐
The '/proc' directory contains information about currently running processes and kernel parameters. A number of tools obtain runtime system information from the contents of the proc directory.
The '/proc' directory contains information about currently running processes and kernel parameters. A number of tools obtain runtime system information from the contents of the proc directory.
If you want to check processor information in Linux, for example, go to the file /proc/cpuinfo. Examine the contents of the /proc/meminfo file to see how much memory your Linux system is using.
๐ง /๐ฟ๐ผ๐ผ๐ - ๐ง๐ต๐ฒ ๐ต๐ผ๐บ๐ฒ ๐ฑ๐ถ๐ฟ๐ฒ๐ฐ๐๐ผ๐ฟ๐ ๐ผ๐ณ ๐๐ต๐ฒ ๐๐๐ฒ๐ฟ
There is also a /root directory, which serves as the home directory for the root user. As a result, rather than /home/root, root's home is at /root. It is not the same as the root directory (/).
There is also a /root directory, which serves as the home directory for the root user. As a result, rather than /home/root, root's home is at /root. It is not the same as the root directory (/).
๐ง /๐๐ฏ๐ถ๐ป - ๐ฆ๐๐๐๐ฒ๐บ ๐ฏ๐ถ๐ป๐ฎ๐ฟ๐ถ๐ฒ๐
This is analogous to the /bin directory. The only difference is that it includes binaries that can only be run by root or a sudo user.
This is analogous to the /bin directory. The only difference is that it includes binaries that can only be run by root or a sudo user.
๐ง /๐๐บ๐ฝ - ๐ง๐ฒ๐บ๐ฝ๐ผ๐ฟ๐ฎ๐ฟ๐ ๐ณ๐ถ๐น๐ฒ๐
As the name implies, this directory stores temporary files. Many applications use this directory to store temporary files. A directory can also be used to store temporary files.
As the name implies, this directory stores temporary files. Many applications use this directory to store temporary files. A directory can also be used to store temporary files.
Keep in mind, however, that the contents of the /tmp directories are deleted when your system restarts, so don't save anything important here.
๐ง /๐๐๐ฟ โ ๐จ๐๐ฒ๐ฟ ๐ฏ๐ถ๐ป๐ฎ๐ฟ๐ถ๐ฒ๐ ๐ฎ๐ป๐ฑ ๐ฝ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ ๐ฑ๐ฎ๐๐ฎ
Here you can find executable files, libraries, source of most of the system programs.
Here are some examples of directories contained in the /usr directory
Here you can find executable files, libraries, source of most of the system programs.
Here are some examples of directories contained in the /usr directory
- /usr/bin - contains basic user commands
- /usr/sbin - contains administrator-specific commands.
- /usr/lib - contains the system libraries
- /usr/sbin - contains administrator-specific commands.
- /usr/lib - contains the system libraries
- /usr/share - contains documentation or files that are shared by all libraries, such as '/usr/share/man', which contains the text of the manpages.
๐ง /๐๐ฎ๐ฟ - ๐ฉ๐ฎ๐ฟ๐ถ๐ฎ๐ฏ๐น๐ฒ ๐ฑ๐ฎ๐๐ฎ ๐ณ๐ถ๐น๐ฒ๐
'/var' directory contains variable data that is expected to grow in size (such as system logging files, printer spool directories, mail, and so on).
'/var' directory contains variable data that is expected to grow in size (such as system logging files, printer spool directories, mail, and so on).
For example:
โ /var/crash - stores information about crashed processes.
โ /var/log - contains log files for the system as well as other applications.
โ /var/crash - stores information about crashed processes.
โ /var/log - contains log files for the system as well as other applications.
โ /var/lib - contains dynamic data files/libraries.
โ /var/spool - spool data of applications.
โ /var/mail - contains user mailbox files.
โ /var/spool - spool data of applications.
โ /var/mail - contains user mailbox files.
๐ง /๐๐ฟ๐ - ๐ฆ๐ฒ๐ฟ๐๐ถ๐ฐ๐ฒ ๐ฑ๐ฎ๐๐ฎ
This is the service directory, which contains information about the services. If you run a server, such as a web server or FTP server, the files accessed by external users will be stored in /srv/.
This is the service directory, which contains information about the services. If you run a server, such as a web server or FTP server, the files accessed by external users will be stored in /srv/.
This information should be sufficient to help you understand the Linux directory structure and how to use it.
That's all! Thank you for getting this far. I hope you find this thread useful.
That's all! Thank you for getting this far. I hope you find this thread useful.
If you found this thread valuable:
1. Toss us a follow for more daily threads on Linux, sysadmin and devops โ
@linuxopsys
2. Like and RT the first tweet so other Linux folks can find it too.
1. Toss us a follow for more daily threads on Linux, sysadmin and devops โ
@linuxopsys
2. Like and RT the first tweet so other Linux folks can find it too.
Loading suggestions...