Understanding linux file system/folder name explanation

The linux system is used by many code developers because of its efficient and direct underlying operations. When it comes to linux, everyone’s general impression is the dark terminal command line. Later, the ubuntu version with a visual desktop was developed based on the linux system. Everyone’s experience takes into account the intuitiveness of the windows system and the convenience of code development for the linux system.

So what is stored in each folder name in the Linux system? This article will summarize.

Folder name explanation

1, /bin and /sbin: executable files or links to executable files (similar to shortcuts)

Bin is the abbreviation of Binary. Common commands such as cp, chmod, cat, etc. are stored here. sbin is the abbreviation of System Binary, and the commands stored here can operate the system configuration. Ordinary users can check the system status through these commands, but if they want to modify it, they need sudo authorization, such as ifconfig, iptables.

2, /boot: files needed for system startup

Such as the grub folder, which is a common boot program.

3, /deb:device files

dev is the abbreviation of device. In Linux, everything exists in the form of files, including hardware devices. such as mouse and keyboard

4, /etc: configuration information of the program

This directory is relatively common, storing a lot of program configuration information, such as apt, and storing the corresponding configuration in /etc/apt, such as the mirror list. If you want to modify the configuration of some system programs, most of them need to be found in the /etc directory.

5, /lib, program dependent file repository

The abbreviation of Library is similar to the library where Windows puts dll files, including the dependencies of executable programs in bin and sbin.

6, /media, user information medium

There will be a folder named after your user name, which contains automatically mounted devices, such as U disk, mobile hard disk, network equipment, etc.

7, /mnt, folders related to device mounting, generally empty

media is where the system automatically mounts the device, here is where you manually mount the device

8, /opt, the abbreviation of Option, the file stored by the user operation

The use of this folder is more casual. Generally speaking, it is better to install the software we downloaded on the browser by ourselves. Of course, the software downloaded by the package management tool may also be stored here

9, /proc, status information of running programs

Abbreviation for process. Most of the files here are named with numbers, and the numbers are Process ID (PID).

The files here are not real files, but some information exchanged between the program and the kernel, for example, you can view the version of the current operating system, or view the status of the CPU: cat /proc/version, head /proc/cpuinfo

10, /root, the directory for the administrator or superuser

11, /run and /sys are used to store the runtime information of certain programs and some information required by the system.

For example, to modify the brightness of the graphics card, sudo vim /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness

However, this data is stored in memory. Once restarted, the information in the /run and /sys directories will be lost, so it cannot be used to save any files.

12, /srv, store service data

Abbreviation for service. For desktop Linux systems, this folder is generally empty, but for Linux servers, resources for Web services or FTP file services can be stored here.

13, /tmp, temporary files for storing programs

Abbreviation for temporary. Temporary files may play an important role. For example, I often hear that a classmate’s Word document crashes, and all the things I wrote are gone. Many text editors in Linux will put a copy of the current text in /tmp as a temporary file. If Your editor crashes unexpectedly, there is still a chance to find a temporary file in /tmp to rescue it.

Of course, the tmp folder will be automatically cleared after the system restarts. If it is not cleared, it means that the system failed to delete some files, and you may need to delete them manually.

14, /usr, store resources not necessary for the system, store some resources added by users

usr is the abbreviation of Universal System Resource, which stores some non-system necessary resources, such as user-installed applications.

The /usr and /usr/local directories also contain the bin and sbin directories, which also store executable files ( command), but different from bin and sbin in the root directory, here are mostly tools used by users, not required by the system.

For example /usr/bin contains the executables for the application Chrome and the goldendict dictionary that I installed through the package manager.

15, /var, stores log information and cannot be deleted automatically

var is the abbreviation of variable. This name is left over from history. Now the main function of this directory is to store log (log) information, such as program crashes, system exceptions, etc. All other information will be recorded here.

16, /home, the user’s home directory

The home directory of ordinary users. In the desktop version of the Linux system, the user’s home directory will have folders such as downloads, videos, music, and desktop. . is a hidden file).

Among them, the .cache folder stores application cache data, and the .config folder stores some application configurations. For example, my Chrome browser configuration is there. But there are still some applications that do not store the configuration in the .config folder, but create a hidden folder by themselves to store their own configuration files and other information. For example, you can see the configuration of Intellij The file is not in .config.

Finally, the .local folder is a bit like /usr/local, and 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, the files that exist here are only available to this user.

That’s why, sometimes a command that can be used by a normal user, with sudo or a superuser, is told that the command cannot be found. Because some commands are in a specific user’s home directory, they are added to the user’s PATH environment variable, and he can use them directly. Of course you can use it as a super user, but you have to write the full absolute path.

Tips

If you modify the system configuration, you can find it in /etc. If you modify the user’s application configuration, you can find it in the hidden files in the user’s home directory.

You can directly enter the command to use on the command line, and its executable files are generally in the following locations:

/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin
/usr/local/sbin
/home/USER/.local/bin
/home/USER/.local/sbin

If you write a script/program and want to call it directly at any time, you can add this script/program to the above directory.

If a program crashes, you can try to find the error message in /val/log, and look for residual temporary files in /tmp.

Device files are in the /dev directory, but generally the system will automatically mount devices such as U disks for you, and you can access the device content in the /media folder.

From: What the hell is the Linux file system :: labuladong’s algorithm cheat sheet