Linux folder


/ — 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.

img

/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.

是Binary的缩写,这个目录存放着最经常使用的命令

  • 比如 cal
  • 比如 cd

在它下面还有 /user/bin/user/local/bin

img

/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.

存放的是启动Linux的时候使用的一些核心文件,包括一些连接文件以及镜像文件

/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.

/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.

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.

类似于windows设备管理器,把所有的硬件以文件的形式存储

img

/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.

所有的系统管理所需要的配置文件和子目录,比如安装mysql数据库,安装完成后,这个mysql的配置文件 mysql.conf 会放入这个目录下

/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.

存放普通用户的主目录,在Linux中每个用户都有一个自己的目录,一般该目录名是以用户的账号命名

img

/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.

系统开机所需要的最基本的动态链接共享库,其作用类似于Windows里的DLL文件。几乎所有的应用程序都需要用到这些共享库。

/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.

这个目录一般情况下是空的,当系统非法关机后,这里就存放了一些文件

这个目录直接看找不到,在cmd中根目录下能看到指令为

cd / # 到根目录下
ls # 展示当前目录的东西

/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.

linux系统会自动识别一些设备,例如U盘,光驱等等,当识别后,linux会把识别的设备挂载到这个目录下

/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/ 上,然后进入该目录就可以查看里面的内容了

d:/myshare 就用到了这个目录,使我们虚拟机linux和windows共享了这个文件夹

/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.

这是给主机额外安装软件所存放的目录。如安装ORACLE数据库就可以放到该目录下。默认为空。

一般我们先把安装文件拷贝到opt目录下面来,便于管理,约定俗成

/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.

这个目录是一个虚拟的目录,它是系统内存的映射,访问这个目录来获取系统信息,一般不能动这个文件

img

/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.

该目录为系统管理员,也称作超级权限者的用户主目录

/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.

/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.

s就是Super User的意思,这里存放的是系统管理员使用的系统管理程序

img

/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.

security-enhanced linux SELinux是一种安全子系统,他能控制程序只能访问特定文件,有三种工作模式,可以自行设置

/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.

RELATED: *How to Find Your Apache Configuration Folder*

service的缩写,该目录存放一些服务启动之后需要提取的数据

/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.

存放一些临时文件

/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.

The /usr/local directory is where locally compiled applications install to by default — this prevents them from mucking up the rest of the system.

这是一个非常重要的目录,用户的很多应用程序和文件都放在这个目录下,类似于windows下的program files目录

/usr/local 是另一个给主机额外安装软件的目录。一般是通过编译源码方式安装的程序。

img

/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.

这个目录中存放着在不断扩充的东西,习惯将经常被修改的目录放在这个目录下。包括各种日志文件


Author: Liang Junyi
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Liang Junyi !
  TOC