Linux file system analysis: the role and usage of each directory
The Linux file system is a complex and organized structure that contains all the files and data required by the operating system and users. There are many different directories in the Linux file system, each with a specific meaning and purpose. If you want to better understand and manage your Linux system, you need to know what these directories are, what they store, and how to use them correctly. In this article, we will introduce you to the most common and important directories in the Linux file system, including /bin, /boot, /dev, /etc, /home, /lib, /lost found, /media, /mnt, /opt, /proc, /root, /run, /sbin, /srv, /sys, /tmp and /usr.
/bin

This is the primary storage location for executable binaries required by the system (hence the name "bin"). These basic binaries are required by the system during the boot process to ensure successful completion. Here you will find basic commands like ls and top.
During the boot process, if /usr/bin is not available, /bin is sometimes provided as a symbolic link at the top level.
/boot
This directory contains all the key files needed to actually boot the operating system. These include kernel files, boot loader files (such as GRUB), and EFI files for modern UEFI systems.
For Linux systems, this directory is one of the most important directories, because if something goes wrong here, your system may not be able to start, or you may not even know where to start.
/dev
/dev is short for "device", which is where Linux stores references to most connected devices on the system, both physical and virtual. Here you can find references to hard drives, USB peripherals, virtual terminals, and even empty devices that you can direct things to so that they disappear.
If you access any kind of device from the command line, even if it's not physical hardware, chances are it exists here.
/etc
Most likely you have researched in the /etc directory before. This is where Linux keeps all its core configuration files, not only for its own programs, but also for third-party programs you install.
If you need to modify the way the program runs, core network settings, or crontab, they all exist in this directory.

/home
This is one of the more descriptive top-level directories. This is exactly where the user's home directory is. Think of it as a separate space that each user has within the operating system. Typically, they own all files and subdirectories in their corresponding home directories.
If you view this directory on a shared machine, you may find many subdirectories named after each specific user. After logging in on most systems, you can reference your home directory using the ~ character in the path. The corresponding path is /home/.
This is the best place to store personal files that are relevant only to you. Pictures, music files, spreadsheets, or the next great novel should all be stored here. You should not store shared program configuration or system-level data here.
/lib, /lib32, /lib64, …
These directories contain shared C libraries and kernel modules. These modules and libraries are the basis for the executable binaries in the /bin directory we mentioned earlier. In other words, in order to actually boot the operating system and use any default binaries, we need the library files in these directories.
Note: If there are multiple library files for different architectures, you will see other lib directories exist.
/lost found
This directory is very simple. Here you will find some files that are corrupted but attempts have been made to recover them. This is usually caused by an unexpected power outage or sometimes a hardware failure.
/media
This is also very intuitive. This is a mount point for mounting removable media. Historically, it was used on CDs, floppy disks, and even Zip disk drives. Now, if you mount any virtual ISO or CD images, they can appear here, along with USB flash drives and other removable flash media.
/mnt This is a more general mount point where you can mount removable media or an entire file system. Today, this is typically used to house external disks, NFS, and other remote file storage.
This directory is empty, you can decide what to mount here and how to mount it.
/opt
This is the abbreviation of "option" and was originally used to store any additional software packages. These packages are not included with the original release of the system and require additional cost.
Today, this is one of the few places where add-on packages can be installed (with or without additional cost). In some cases, the distribution may not use /opt at all, but this is one location where you will find third-party package data and their static configuration files.
/proc
This is a unique Linux directory. You won't store anything here, and in fact the operating system won't store anything here. This is the information center for the Linux kernel. All "files" in this directory are not ordinary files. They contain metrics about processes, memory, and other subsystems. These special files are like windows into the workings of the kernel.
By simply reading the files in this directory, you can obtain some of the same data that other binaries obtain.
/root
This is another simple, intuitive directory. This is the root user's home directory. If you are logged into the system as the root user, you will find that your home directory is now /root instead of /home/root as expected. This is for security reasons in case /home is mounted on an inaccessible or worse, broken remote partition.
/run
This directory handles more startup and runtime information. Typically you will find the process ID or PID file in this location. These files describe where a process runs so that other programs can later find it and control or reference it.
In addition, other temporary files can be placed here, such as lock files and socket information. This directory is intended to hold runtime information, not persistent data.
/sbin
Similar to /bin, the /sbin directory also contains executable binary files required by the system. The difference is that the binary files in this directory have special purposes. They are both specifically designed to perform administrator functions on the system. This means they are powerful enough to make significant modifications or maintenance to the operating system, so they are usually found here.
You won't find binaries like echo or cat here. This directory is reserved for tools like fdisk or usermod.
/srv
This is another very general directory. This directory is used to store files that the system is responsible for "providing". For example, if the host was a web server, you might place all your HTML and image resources here.
/sys
Depending on the distribution you are using and its version, you may or may not have a /sys directory on your system. This directory is similar to the /proc directory in that it contains device and kernel information, but is presented in a more structured format.
/tmp
Another simple directory. This is a directory for temporary files. You can store almost anything you (or the program) like here, but you can't expect it to last forever. Especially between reboots.
If you need to stage some unimportant data or check the output format of a certain file, putting it here is an option. An added bonus is that if you forget about it, it will probably disappear on its own.
/usr
This directory may require writing a special article to introduce it. According to the Linux Foundation's FHS specification, it is described as:
"Shared, read-only data."
This essentially means that it should be able to be easily transferred between hosts and have the same unmodified structure and hierarchy. Normally, this directory does not contain any unique host data. The idea behind this is that the entirety of /usr can be mounted in read-only mode on another system without problems.
However, in practice, this directory is indeed used to store arbitrary information. In some cases, you will find files in /usr/share or /usr/local. You will also find program compilations or custom scripts placed in /usr/local/bin.
Generally speaking, it is recommended to store configuration or special data that does not fall into any of the previous categories in our next and last directory.
/var
This is the abbreviation of "variable", and this is where the variable data is saved.
Here are some of the things traditionally kept here:
- Printer spools
- Lock files
- Debian apt and other running program caches
- Email data
- Logs The main purpose of the
/var directory is to hold any dynamic data used and changed by the system at runtime. If you need to write to logs or keep a dynamic .conf file somewhere, you've come to the right place.
Additionally, there is the /var/local directory, which in my experience often becomes a comprehensive storage directory for miscellaneous configuration files and other data that doesn't quite fit into other categories.
Summarize
Through this article, you should have a clearer understanding of each directory in the Linux file system, know their meaning and purpose, and how to choose the appropriate location according to different types of files. The Linux file system is a carefully designed structure that provides the operating system and users with an efficient, secure, and flexible file management method. Mastering the knowledge of Linux file systems can allow you to better use and maintain Linux systems, and can also avoid some common mistakes and problems.
The above is the detailed content of Linux file system analysis: the role and usage of each directory. For more information, please follow other related articles on the PHP Chinese website!

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)