linux 目录结构
If you’re coming from Windows, the Linux file system structure can seem particularly alien. The C:\ drive and drive letters are gone, replaced by a / and cryptic-sounding directories, most of which have three letter names.
如果您来自Windows,那么Linux文件系统的结构似乎特别陌生。 C:\驱动器和驱动器号不见了,取而代之的是一个/和听起来有些神秘的目录,其中大多数都有三个字母名称。
The Filesystem Hierarchy Standard (FHS) defines the structure of file systems on Linux and other UNIX-like operating systems. However, Linux file systems also contain some directories that aren’t yet defined by the standard.
文件系统层次结构标准(FHS)定义了Linux和其他类似UNIX的操作系统上文件系统的结构。 但是,Linux文件系统还包含一些标准尚未定义的目录。
/ –根目录 (/ – The Root Directory)
Everything on your Linux system is located under the / directory, known as the root directory. You can think of the / directory as being similar to the C:\ directory on Windows – but this isn’t strictly true, as Linux doesn’t have drive letters. While another partition would be located at D:\ on Windows, this other partition would appear in another folder under / on Linux.
Linux系统上的所有内容都位于/目录(称为根目录)下。 您可以将/目录视为类似于Windows上的C:\目录–但这并非完全正确,因为Linux没有驱动器号。 在Windows上,另一个分区位于D:\,而在Linux上,该另一个分区将显示在/下的另一个文件夹中。
/ bin –基本用户二进制文件 (/bin – Essential User Binaries)
The /bin directory contains the essential user binaries (programs) that must be present when the system is mounted in single-user mode. Applications such as Firefox are stored in /usr/bin, while important system programs and utilities such as the bash shell are located in /bin. The /usr directory may be stored on another partition – placing these files in the /bin directory ensures the system will have these important utilities even if no other file systems are mounted. The /sbin directory is similar – it contains essential system administration binaries.
/ bin目录包含在单用户模式下安装系统时必须存在的基本用户二进制文件(程序)。 诸如Firefox之类的应用程序存储在/ usr / bin中,而重要的系统程序和实用程序(例如bash shell)则位于/ bin中。 / usr目录可以存储在另一个分区上-将这些文件放在/ bin目录中可确保即使没有安装其他文件系统,系统也将具有这些重要的实用程序。 / sbin目录类似–它包含基本的系统管理二进制文件。
/ boot –静态启动文件 (/boot – Static Boot Files)
The /boot directory contains the files needed to boot the system – for example, the GRUB boot loader’s files and your Linux kernels are stored here. The boot loader’s configuration files aren’t located here, though – they’re in /etc with the other configuration files.
/ boot目录包含启动系统所需的文件,例如,GRUB引导加载程序的文件和Linux内核存储在此处。 但是,引导加载程序的配置文件不在此处-与其他配置文件位于/ etc中。
/ cdrom – CD-ROM的历史挂载点 (/cdrom – Historical Mount Point for CD-ROMs)
The /cdrom directory isn’t part of the FHS standard, but you’ll still find it on Ubuntu and other operating systems. It’s a temporary location for CD-ROMs inserted in the system. However, the standard location for temporary media is inside the /media directory.
/ cdrom目录不是FHS标准的一部分,但是您仍然可以在Ubuntu和其他操作系统上找到它。 这是插入系统的CD-ROM的临时位置。 但是,临时媒体的标准位置在/ media目录中。
/ dev –设备文件 (/dev – Device Files)
Linux exposes devices as files, and the /dev directory contains a number of special files that represent devices. These are not actual files as we know them, but they appear as files – for example, /dev/sda represents the first SATA drive in the system. If you wanted to partition it, you could start a partition editor and tell it to edit /dev/sda.
Linux将设备公开为文件,/ dev目录包含许多代表设备的特殊文件。 这些不是我们所知道的实际文件,而是显示为文件–例如,/ dev / sda表示系统中的第一个SATA驱动器。 如果要对其进行分区,可以启动分区编辑器,并告诉它编辑/ dev / sda。
This directory also contains pseudo-devices, which are virtual devices that don’t actually correspond to hardware. For example, /dev/random produces random numbers. /dev/null is a special device that produces no output and automatically discards all input – when you pipe the output of a command to /dev/null, you discard it.
该目录还包含伪设备,它们是实际上与硬件不对应的虚拟设备。 例如,/ dev / random产生随机数。 / dev / null是一种特殊的设备,它不产生任何输出并自动丢弃所有输入–当将命令的输出通过管道传输到/ dev / null时,将其丢弃。
/ etc –配置文件 (/etc – Configuration Files)
The /etc directory contains configuration files, which can generally be edited by hand in a text editor. Note that the /etc/ directory contains system-wide configuration files – user-specific configuration files are located in each user’s home directory.
/ etc目录包含配置文件,通常可以在文本编辑器中手动对其进行编辑。 请注意,/ etc /目录包含系统范围的配置文件–特定于用户的配置文件位于每个用户的主目录中。
/ home –主文件夹 (/home – Home Folders)
The /home directory contains a home folder for each user. For example, if your user name is bob, you have a home folder located at /home/bob. This home folder contains the user’s data files and user-specific configuration files. Each user only has write access to their own home folder and must obtain elevated permissions (become the root user) to modify other files on the system.
/ home目录包含每个用户的主文件夹。 例如,如果您的用户名为bob,则您的主文件夹位于/ home / bob。 此主文件夹包含用户的数据文件和用户特定的配置文件。 每个用户仅对其自己的主文件夹具有写访问权,并且必须获得提升的权限(成为root用户)才能修改系统上的其他文件。
/ lib –基本共享库 (/lib – Essential Shared Libraries)
The /lib directory contains libraries needed by the essential binaries in the /bin and /sbin folder. Libraries needed by the binaries in the /usr/bin folder are located in /usr/lib.
/ lib目录包含/ bin和/ sbin文件夹中的基本二进制文件所需的库。 / usr / bin文件夹中的二进制文件所需的库位于/ usr / lib中。
/ lost + found –恢复的文件 (/lost+found – Recovered Files)
Each Linux file system has a lost+found directory. If the file system crashes, a file system check will be performed at next boot. Any corrupted files found will be placed in the lost+found directory, so you can attempt to recover as much data as possible.
每个Linux文件系统都有一个lost + found目录。 如果文件系统崩溃,则将在下次启动时执行文件系统检查。 找到的任何损坏的文件将放置在lost + found目录中,因此您可以尝试恢复尽可能多的数据。
/ media –可移动媒体 (/media – Removable Media)
The /media directory contains subdirectories where removable media devices inserted into the computer are mounted. For example, when you insert a CD into your Linux system, a directory will automatically be created inside the /media directory. You can access the contents of the CD inside this directory.
/ media目录包含安装在计算机中的可移动媒体设备所在的子目录。 例如,当您将CD插入Linux系统时,将在/ media目录中自动创建一个目录。 您可以在此目录中访问CD的内容。
/ mnt –临时挂载点 (/mnt – Temporary Mount Points)
Historically speaking, the /mnt directory is where system administrators mounted temporary file systems while using them. For example, if you’re mounting a Windows partition to perform some file recovery operations, you might mount it at /mnt/windows. However, you can mount other file systems anywhere on the system.
从历史上看,/ mnt目录是系统管理员在使用它们时挂载临时文件系统的位置。 例如,如果要安装Windows分区以执行某些文件恢复操作,则可以将其安装在/ mnt / windows。 但是,您可以在系统上的任何位置挂载其他文件系统。
/ opt –可选软件包 (/opt – Optional Packages)
The /opt directory contains subdirectories for optional software packages. It’s commonly used by proprietary software that doesn’t obey the standard file system hierarchy – for example, a proprietary program might dump its files in /opt/application when you install it.
/ opt目录包含可选软件包的子目录。 不符合标准文件系统层次结构的专有软件通常使用它-例如,专有程序在安装时可能会将其文件转储到/ opt / application中。
/ proc –内核和进程文件 (/proc – Kernel & Process Files)
The /proc directory similar to the /dev directory because it doesn’t contain standard files. It contains special files that represent system and process information.
/ proc目录类似于/ dev目录,因为它不包含标准文件。 它包含代表系统和过程信息的特殊文件。
/ root –根主目录 (/root – Root Home Directory)
The /root directory is the home directory of the root user. Instead of being located at /home/root, it’s located at /root. This is distinct from /, which is the system root directory.
/ root目录是root用户的主目录。 它不是位于/ home / root,而是位于/ root。 这不同于/,后者是系统根目录。
/ run –应用程序状态文件 (/run – Application State Files)
The /run directory is fairly new, and gives applications a standard place to store transient files they require like sockets and process IDs. These files can’t be stored in /tmp because files in /tmp may be deleted.
/ run目录是一个相当新的目录,它为应用程序提供了一个标准位置来存储所需的临时文件,例如套接字和进程ID。 这些文件无法存储在/ tmp中,因为/ tmp中的文件可能已删除。
/ sbin –系统管理二进制文件 (/sbin – System Administration Binaries)
The /sbin directory is similar to the /bin directory. It contains essential binaries that are generally intended to be run by the root user for system administration.
/ sbin目录类似于/ bin目录。 它包含基本二进制文件,这些二进制文件通常由root用户运行以进行系统管理。
/ selinux – SELinux虚拟文件系统 (/selinux – SELinux Virtual File System)
If your Linux distribution uses SELinux for security (Fedora and Red Hat, for example), the /selinux directory contains special files used by SELinux. It’s similar to /proc. Ubuntu doesn’t use SELinux, so the presence of this folder on Ubuntu appears to be a bug.
如果您Linux发行版使用SELinux进行安全保护(例如,Fedora和Red Hat),则/ selinux目录包含SELinux使用的特殊文件。 它类似于/ proc。 Ubuntu不使用SELinux,因此在Ubuntu上存在此文件夹似乎是一个错误。
/ srv –服务数据 (/srv – Service Data)
The /srv directory contains “data for services provided by the system.” If you were using the Apache HTTP server to serve a website, you’d likely store your website’s files in a directory inside the /srv directory.
/ srv目录包含“系统提供的服务的数据”。 如果您使用Apache HTTP服务器为网站提供服务,则可能会将网站的文件存储在/ srv目录中的目录中。
/ tmp –临时文件 (/tmp – Temporary Files)
Applications store temporary files in the /tmp directory. These files are generally deleted whenever your system is restarted and may be deleted at any time by utilities such as tmpwatch.
应用程序将临时文件存储在/ tmp目录中。 通常,每当系统重新启动时,这些文件都会被删除,tmpwatch等实用程序可能会随时删除这些文件。
/ usr –用户二进制文件和只读数据 (/usr – User Binaries & Read-Only Data)
The /usr directory contains applications and files used by users, as opposed to applications and files used by the system. For example, non-essential applications are located inside the /usr/bin directory instead of the /bin directory and non-essential system administration binaries are located in the /usr/sbin directory instead of the /sbin directory. Libraries for each are located inside the /usr/lib directory. The /usr directory also contains other directories – for example, architecture-independent files like graphics are located in /usr/share.
/ usr目录包含用户使用的应用程序和文件,而不是系统使用的应用程序和文件。 例如,非必需应用程序位于/ usr / bin目录中,而不是/ bin目录中;非必需系统管理二进制文件位于/ usr / sbin目录中,而不是/ sbin目录中。 每个库都位于/ usr / lib目录中。 / usr目录还包含其他目录-例如,与体系结构无关的文件(例如图形)位于/ usr / share中。
The /usr/local directory is where locally compiled applications install to by default – this prevents them from mucking up the rest of the system.
默认情况下,/ usr / local目录是本地编译的应用程序安装到的目录–这样可以防止它们破坏系统的其余部分。
/ var –可变数据文件 (/var – Variable Data Files)
The /var directory is the writable counterpart to the /usr directory, which must be read-only in normal operation. Log files and everything else that would normally be written to /usr during normal operation are written to the /var directory. For example, you’ll find log files in /var/log.
/ var目录是/ usr目录的可写副本,/ usr目录在正常操作中必须为只读。 日志文件和在正常操作期间通常会写入/ usr的所有其他内容都写入/ var目录。 例如,您将在/ var / log中找到日志文件。
For more detailed technical information about the Linux file system hierarchy, consult the Filesystem Hierarchy Standard documentation.
有关Linux文件系统层次结构的更多详细技术信息,请查阅Filesystem Hierarchy Standard文档。
翻译自: https://www.howtogeek.com/117435/htg-explains-the-linux-directory-structure-explained/
linux 目录结构