1. 程式人生 > 實用技巧 >linux 目錄結構_Linux目錄結構,解釋

linux 目錄結構_Linux目錄結構,解釋

linux 目錄結構

linux 目錄結構

image

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上,該另一個分割槽將顯示在/下的另一個資料夾中。

image

/ 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目錄類似–它包含基本的系統管理二進位制檔案。

image

/ 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時,將其丟棄。

image

/ 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使用者)才能修改系統上的其他檔案。

image

/ 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目錄,因為它不包含標準檔案。 它包含代表系統和過程資訊的特殊檔案。

image

/ 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使用者執行以進行系統管理。

image

/ 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目錄是本地編譯的應用程式安裝到的目錄–這樣可以防止它們破壞系統的其餘部分。

image

/ 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 目錄結構