Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of each directory in Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what the role of each directory in the Linux system is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Type of file system

LINUX has four basic file system types: normal files, directory files, connection files, and special files, which can be identified by the file command.

Ordinary files: such as text files, C language meta-code, SHELL scripts, binary executable files, etc., you can use cat, less, more, vi, emacs to view the content, use mv to rename.

Directory files: including file names, subdirectory names and their pointers. It is the only place where LINUX stores the file name, and you can use ls to list directory files.

Connection files: those directory entries that point to the same index node. To see yes with ls, the flag for connecting to the file begins with l, and the face of the file points to the connected file with "- >".

Special files: some devices of LINUX, such as disks, terminals, printers, etc., are represented in the file system, then a class of files are special files, often placed in the / dev directory. For example, floppy drive An is called / dev/fd0. LINUX does not have the concept of C:, but uses / dev/had from the first hard drive.

One of the most puzzling questions for newcomers to linux is where are the files stored? The directory structure of linux looks a little strange, especially for newcomers who have transferred from windows. So, let's talk about the main directories under linux and what they are used for.

/

This is the root directory. The mothership. The home field. The one and only top directory for your whole computer. Everything, and I mean EVERYTHING starts here. When you type'/ home' what you're really saying is "start at / and then go to the home directory."

/

This is the root directory. For your computer, there is one and only one root directory. Everything. I mean, everything starts here. For example: when you type "/ home" into the terminal, you are actually telling the computer to start with / (root) and then enter the home directory.

/ root

This is where the root user lives. The root user is the god of your system. Root can do anything, up to and including removing your entire filesystem. So be careful using root.

/ root

This is the directory of the system administrator (root user). To the system, the system administrator is like God, it can do anything to the system, even delete your files. Therefore, please be careful with your root account.

/ bin

Here's where your standard linux utilities (read programs) live-things like "ls" and "vi" and "more" Generally this directory is included in your path. What this means is that if you type 'ls', / bin is one of the places your shell will look to see if' ls' means anything.

/ bin

There are standard (or default) linux tools such as "ls", "vi", "more" and so on. In general, this directory is already included in your "path" system variable. What do you mean? That is: when you type ls in the terminal, the system will go to the / bin directory to find out if there is a ls program.

/ etc

Here's where the administrative and system configuration stuff lives. For instance, if you have samba installed, and you want to modify the samba configuration files, you'd find them in / etc/samba.

/ etc

The files of system configuration are mainly stored here. For example: you have installed the samba suite, and when you want to modify the samba configuration files, you will find them in the / etc/samba directory.

/ dev

Here's where files that control peripherals live. Talking to a printer? Your computer is doing it from here. Same goes for disk drives, usb devices, and other such stuff.

/ dev

Files related to the equipment (including peripherals) are mainly stored here (both unix and linux systems treat the equipment as files). Do you want to connect to the printer? This is where the system starts to work. In addition, some disk drivers, USB drivers and so on are placed in this directory.

/ home

Here's where your data is stored. Config files specific to users, your Desktop folder (whick makes your desktop what it is), and any data related to your user. Each user will have their own / home/username folder, with the exception of the root user.

/ home

Your personal data is mainly stored here. Specific settings files for each user, user's desktop folder, and user data are all placed here. Each user has its own user directory, located at: / home/ user name. Except for root users, of course.

/ tmp

This is the Temporary folder. Think of it as a scratch directory for your Linux system. Files that won't be needed by programs once their used once or twice are put here. Many Linux systems are set to automatically wipe the / tmp folder at certain intervals, so don't put things you want to keep here.

/ tmp

This is a temporary directory. For some programs, some files are no longer used after they have been used once or twice, and files like this are placed here. Some linux systems automatically clean up this directory on a regular basis, so don't put important data here.

/ usr

Here's where you'll find extra utilities that don't fit under / bin or / etc. Things like games, printer utilities, and whatnot. / usr is divided into sections like / usr/bin for programs, / usr/share for shared data like sound files or icons, / usr/lib for libraries whick cannot be directly run but are essential for running other programs.Your package manager takes care of the things in / usr for you.

/ usr

In this directory, you can find additional tools that don't fit in the / bin or / etc directory. For example, like games, some printing tools to pull and so on. The / usr directory contains many subdirectories: the / usr/bin directory is used to store programs; / usr/share is used to store some shared data, such as music files or icons; and the / usr/lib directory is used to store some library files that cannot be run directly but are necessary for many programs to run. Your package manager (should be Synaptic) will automatically manage the / usr directory for you.

/ opt

Here's where optional stuff is put. Trying out the latest Firefox beta? Install it to / opt where you can delete it without affecting other settings. Programs in here usually live inside a single folder whick contains all of their data, libraries, etc.

/ opt

The optional programs are mainly stored here. Do you want to try the latest firefox beta? Then install it in the / opt directory so that when you finish trying and want to delete firefox, you can delete it directly without affecting any other settings in the system. For a program installed in the / opt directory, all its data, library files, and so on are placed in the same directory.

For example: the beta version of firefox just installed can be loaded into the / opt/firefox_beta directory, and the / opt/firefox_beta directory contains all the files, libraries, data, and so on needed to run the firefox. To delete firefox, you only need to delete the / opt/firefox_beta directory, which is very simple.

/ usr/local

This is where most manually installed (ie. Outside of your package manager) software goes. It has the same structure as / usr. It is a good idea to leave / usr to your package manager and put any custom scripts and things into / usr/local, since nothing important normally lives in / usr/local.

/ usr/local

The main storage here is for software that is installed manually, that is, software that is not installed through Synaptic or apt-get. It has a similar directory structure to the / usr directory. I think it's a good idea to let the package manager manage the / usr directory and put the custom scripts (scripts) under the / usr/local directory.

/ media

Some distros use this folder to mount things like usb disks, cd or dvd drives and other filesystems.

/ media

Some linux distributions use this directory to mount usb removable hard drives (including USB drives), CD/DVD drives, and so on.

Add:

The commands needed by the / bin system are located in this directory, such as ls, cp, mkdir, etc.; the functions are similar to / usr/bin, and the files in this directory are executable commands that can be used by ordinary users. The most basic commands needed for the base system are placed here (/ usr/bin and / usr/sbin are similar to the corresponding directories under the "/" root directory (/ bin and / sbin), but are not used for basic startup (for example, in emergency maintenance). Most of the commands are in this directory. ).

The kernel of / boot Linux and the files needed to boot the system program, such as the vmlinuz initrd.img file, are located in this directory. In general, the GRUB or LILO system boot manager is also located in this directory.

/ lost+found in ext2 or ext3 file systems, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. When the system starts up, the fsck tool will check here and repair the corrupted file system. Sometimes there is a problem with the system, and a lot of files are moved to this directory, which may be repaired manually or moved to the original location.

The / mnt directory is generally used to store the mount directory for mounting storage devices, such as cdrom and other directories. See the definition of / etc/fstab. Sometimes we can let the system boot to mount the file system automatically, and it is also possible to put the mount point here. It mainly depends on how it is defined in / etc/fstab; for example, the optical drive can be mounted to / mnt/cdrom.

/ opt means optional, and some packages will also be installed here, that is, custom packages, such as in Fedora Core 5.0, where OpenOffice is installed. Some of the packages we compiled ourselves can be installed in this directory; software installed through the source package can be installed through the. / configure-- prefix=/opt/ directory.

When the / proc operating system is running, process information and kernel information (such as cpu, hard disk partition, memory information, etc.) are stored here. The / proc directory disguises the mount directory of the file system proc. Proc is not a real file system, and its definition can be found in / etc/fstab.

/ sbin is mostly related to system management command storage, is the super rights user root executable command storage, ordinary users do not have the authority to execute commands under this directory, this directory and / usr/sbin; / usr/X11R6/sbin or / usr/local/sbin directory is similar; we just remember that all directory sbin contains root permissions can only be executed.

/ usr this is the directory where the system stores programs, such as commands, help files, etc. There are many files and directories in this directory. When we install a package officially provided by a Linux distribution, it is mostly installed here. If any server configuration files are involved, the configuration files will be installed in the / etc directory. The / usr directory includes the font directory / usr/share/fonts, the help directory / usr/share/man or / usr/share/doc, the general user executable file directory / usr/bin or / usr/local/bin or / usr/X11R6/bin, the super permission user root executable command storage directory, such as / usr/sbin or / usr/X11R6/sbin or / usr/local/sbin, and the program header file storage directory / usr/include.

The content of the / var directory is constantly changing. If you look at the name, we can understand it as the abbreviation of vary. Under / var, there is / var/log, which is the directory used to store system logs. The / var/www directory defines the Apache server site storage directory; / var/lib is used to store some library files, such as MySQL, and the storage place of the MySQL database.

A tip about the / opt directory

In Linux, the / opt directory is the directory where some large or special software is stored. For example, Google browser (Google Chrome) is installed in / opt by default. But we don't usually divide the opt into a separate zone, because most of the time / opt is empty, even if the software is installed, and some of the software capacity is relatively large, so it will occupy / capacity. We can set up a directory in other places you like to "transfer" / opt. For example, my / usr is divided into a separate zone with a capacity of 50G. Don't waste such a big space, do you? And / usr is the place where the software is installed, so I can set up a folder called opt under / usr, then right-click on opt under this / usr, select "create Link", get a file called "Link to opt", then cut the file to /, delete the original / opt, and rename "Link to opt" to opt. Later, the software we installed at / opt is actually installed under / usr/opt (actually a symbolic link).

The / usr/local directory is generally used to store the directory where the user compiles and installs the software; the software is usually installed through the source package, if no specific installation directory is specified, it is usually installed in this directory. There are subdirectories under this directory. See for yourself.

Things common to / usr/share systems are stored, such as / usr/share/fonts is the font directory, / usr/share/doc and / usr/share/man help files.

/ var/log system log is stored. To analyze the log, you need to see what is in this directory.

/ var/spool printers, mail, proxy servers and other spooling directories

On the role of each directory in the Linux system is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report