Introduction to Linux system file directory
"TLDR: This article introduces the file directory distribution of Linux systems, including `/bin`, `/sbin`, `/boot`, `/dev`, `/etc`, `/lib`, `/media`, `/mnt`, `/opt`, `/proc`, `/root`, `/run`, `/sys`, `/srv`, `/tmp`, `/usr`, `/var`, `/home`, etc."
Overall distribution of file system

/bin and /sbin
bin is the abbreviation of Binary, which stores executable files or links to executable files (similar to shortcuts)
The execution files of common cp, chmod, cat and other commands are stored here. All files in the /bin folder are executable binary files (without suffix)
\sbin is the abbreviation of System Binary. The commands stored here can operate the system configuration, and you can view some status of the system here (for example, the common ifconfig can view network card information, iptables and other commands are stored here)
/boot
Here are the files needed for system startup. Some boot programs are here.
/dev
dev is the abbreviation of device. In Linux, everything is a file, and device hardware is also stored in the form of files;
For example, if an external hard disk is mounted, files such as "sda1", "sda2", and "sda3" will appear in this folder. The following numbers represent the hard disk partition. Additionally, devices like mice, keyboards, and cameras can also be found here
/etc
This folder mainly stores the configuration files of many programs, such as apt and Nginx;
The apt configuration file is under /etc/apt; the nginx configuration file is under /etc/nginx
##/lib
lib is the abbreviation of Library, which is similar to the dll file library under Windows and contains the dependent libraries required by the program. For example, the dependencies of executable files stored under /bin and /sbin
/media
There will be a folder named after your username, which contains automatically mounted devices, such as USB flash drives, mobile hard drives, network devices, etc.
For example, if I insert a USB flash drive into my computer, the system will automatically mount the USB flash drive to the /media/fdl folder for me (my username is fdl). If I want to access the contents of the USB flash drive, I can find it there.
/mnt
This is also a folder related to device mounting, usually an empty folder.
The media folder is where the system automatically mounts devices, and here is where you manually mount devices.
For example, we just saw a lot of devices in dev. If you want to open some devices to see the contents inside, you can mount the devices to the mnt directory through commands.
But generally speaking, today's operating systems are very smart. You almost don't need to do operations such as mounting devices manually. They are automatically mounted to the media directory.
/opt
opt is the abbreviation of Option. The use of this folder is relatively casual. Generally speaking, it is better to install the software we downloaded on the browser here. Of course, software downloaded by package management tools may also be stored here.
##/proc
proc is the abbreviation of process, which stores the status information of all running programs.
This folder will store a bunch of numerically named subfolders. The number here represents the ID of a process (process id).
You can also view some system information here:
/proc/version : Linux operating system version
/proc/cpuinfo: CPU status
/root
root user's home directory
/run and /sys
Used to store the running information of certain programs and some information needed by the system
/srv
srv is the abbreviation of service and is mainly used to store service data.
For desktop Linux systems, this folder is generally empty, but for Linux servers, resources from Web services or FTP file services can be stored here.
/tmp
tmp is the abbreviation of temporary, which stores temporary files of some programs.
/usr
usr is the abbreviation of Universal System Resource, which stores some non-system necessary resources, such as applications installed by users.
The /usr and /usr/local directories also contain the bin and sbin directories, which also store executable files (commands). However, unlike the bin and sbin in the root directory, most of them are tools used by users rather than required by the system.
/var
var is the abbreviation of variable. This name is left over from history. Now the main function of this directory is to store log information. For example, information such as program crashes, firewall detected exceptions, etc. will be recorded here, in /var/log.
/home
The .cache folder stores application cache data, and the .config folder stores part of the application's configuration. For example, my Chrome browser configuration is there. However, some applications do not store configurations in the .config folder, but create a hidden folder to store their own configuration files and other information. For example, you can see that the Intellij configuration file is not in .config.
Finally, let’s talk about the .local folder, which is a bit like /usr/local. There is also a bin folder in it, which also stores executable files. For example, my python pip and some tools installed by pip are stored in the ~/.local/bin directory. However, files that exist here can only be used by this user.