Linux centOS directory structure detailed version

 

from  :  http://www.iteye.com/topic/1125162

 

 

I have been using linux for more than a year. Recently, I have been maintaining the system host of the website. Below is the linux directory structure. I am using the centos system. I have not published a blog post for a long time. Record your own linux bit by bit.

 

 linux directory structure

 

 

/: root directory, generally only directories are stored in the root directory, no files are stored. /etc, /bin, /dev, /lib, /sbin should be placed in a partition with the root directory
/bin:/usr/bin: executable The directory of binary files, such as the commonly used commands ls, tar, mv, cat, etc.
/boot: place some files used when the linux system starts. /boot/vmlinuz is the Linux kernel file, and /boot/gurb. A separate partition is recommended, and the partition size is 100M
. /dev: To store the device files under the Linux system, accessing a file in this directory is equivalent to accessing a device. The common method is to mount the CD-ROM drive mount /dev/cdrom /mnt.
/etc: The directory where the system configuration files are stored. It is not recommended to store executable files in this directory. Important configuration files are /etc/inittab, /etc/fstab, /etc/init.d, /etc/X11, /etc Remember to back up /sysconfig, /etc/xinetd.d before modifying the configuration files. Note: /etc/X11 stores settings related to x windows.
/home: The default user home directory of the system. When adding a user account, the user's home directory is stored in this directory. ~ represents the current user's home directory, and ~test represents the user test's home directory. It is recommended to partition separately and set up a larger disk space to facilitate users to store data
/lib:/usr/lib:/usr/local/lib: The directory of the function library used by the system. During the execution of the program, it needs to call some additional The function library is required for the parameter, and the more important directory is /lib/modules.
/lost+fount: When an error occurs due to a system exception, some missing pieces will be placed in this directory. Usually, this directory will automatically appear in the device directory. If the hard disk is loaded in /disk, the directory /disk/lost+found
/mnt:/media will be automatically generated in this directory: the default mount point of the CD, usually the CD is mounted under /mnt/cdrom, it is not necessarily, it can be Choose any location to mount.
/opt: The directory where additional software is installed on the host. For example: the Fedora community development software used by FC4, if you want to install the new KDE desktop software by yourself, you can install the software in this directory. In the previous Linux system, it is customary to place
/proc in the /usr/local directory: the data in this directory is all in memory, such as the system core, external devices, and network status. Since the data is stored in the memory, it does not occupy disk space. , the more important directories are /proc/cpuinfo, /proc/interrupts, /proc/dma, /proc/ioports, /proc/net/*, etc.
/root: the home directory of the system administrator root, the first system to start The partition is /, so it is best to put /root and / under one partition.
/sbin:/usr/sbin:/usr/local/sbin: Place executable commands used by system administrators, such as fdisk, shutdown, mount, etc. Different from /bin, these directories are commands used by the system administrator root, and ordinary users can only "view" but not set and use them.
/tmp: The directory where general users or programs that are being executed temporarily store files, which can be accessed by anyone, and important data cannot be placed in this directory
/srv: The data directory that needs to be accessed after the service is started, such as the web page data that the www service needs to access Stored in /srv/www
/usr: application storage directory, /usr/bin stores application programs, /usr/share stores shared data, /usr/lib stores some function library files that cannot be directly run, but are necessary for many programs to run. /usr/local: Stores software upgrade packages. /usr/share/doc: The directory where the system description files are stored. /usr/share/man: The program description file is stored in the directory. When using man ls, the content of /usr/share/man/man1/ls.1.gz will be queried. It is recommended to partition separately and set a larger disk space
/var: Place the system Files that change frequently during execution, such as the log file
/var/log that changes at any time, /var/log/message: the directory where all log files are stored, /var/spool/mail: the directory where mail is stored, /var/run: After the program or service is started

, its PID is stored in this directory. It is recommended to partition a separate partition and set a larger disk space
  
------------------------------------- --

/dev: The directory
  dev is the English abbreviation of device. The /dev directory is important to all users. Because in this directory contains all the external devices used in Linux system. But here is not the driver of the external device, this and

Windows and dos operating systems are different. It's actually a port to access these external devices. We can easily access these external devices, and it is no different from accessing a file or a directory.

  Linux follows the Unix style and treats all devices as one file.

  There are two types of device files: block device files (b) and character device files (c).

  Device files are generally stored in the /dev directory. The common device files are described as follows:

  /dev/hd[at]: IDE device

  /dev /sd[az]: SCSI device

  /dev/fd[0-7]: Standard floppy drive

  /dev/md[0-31]: Soft raid device

  /dev/loop[0-7]: Local loopback device

  /dev/ram [0-15]: memory

  /dev/null: infinite data receiving device, equivalent to black hole

  /dev/zero: infinite zero resources

  /dev/tty[0-63]: virtual terminal

  /dev/ttyS[0-3]: Serial

  /dev/lp[0-3]: Parallel

  /dev/console: Console

  /dev/fb[0-31]: framebuffer

  /dev/cdrom => /dev/hdc

  /dev/modem => /dev/ttyS [0-9]

  /dev/pilot => /dev/ttyS[0-9]

  /dev/random: random number device

  /dev/urandom: random number device

  (PS: random number device, I will write a blog to summarize it later)

  How are the nodes in the /dev directory created?

  devf or udev will automatically create them for you.

  Kobject is the basis of the sysfs file system, and udev obtains newly created devices by monitoring and detecting sysfs.

---------------------------------------

/etc: The directory
  contains many files. Many network configuration files are also in /etc.
/etc/rc or /etc/rc.d or /etc/rc*.d 
  scripts or directories of scripts that run when starting, or changing runlevels.
/etc/passwd 
  user database , where the fields give the username, real name, home directory, encrypted password, and other information about the user. The mount -a command (in /etc/rc or equivalent startup file) automatically when
/etc/fstab 
  starts List of file systems for mount. Under Linux, it also includes information about swap areas enabled with swapon -a.
/etc/group  
  is similar to /etc/passwd, but describes groups instead of users.
/etc/inittab 
  init configuration file. The output of
/etc/issue 
  getty at the login prompt. Usually includes a short description of the system or a welcome message. The content is determined by the system administrator.
/etc/motd 
  Message Of The Day,成功登录后自动输出.内容由系统管理员确定.经常用于通告信息,如计划关机时间的警告.
/etc/mtab 
  当前安装的文件系统列表.由scripts初始化,并由mount 命令自动更新.需要一个当前安装的文件系统的列表时使用,例如df 命令.
/etc/shadow 
  在安装了影子口令软件的系统上的影子口令文件.影子口令文件将/etc/passwd 文件中的加密口令移动到/etc/shadow 中,而后者只对root可读.这使破译口令更困难.
/etc/login.defs 
  login 命令的配置文件.
/etc/printcap 
  类似/etc/termcap ,但针对打印机.语法不同.
/etc/profile , /etc/csh.login , /etc/csh.cshrc 
  登录或启动时Bourne或C shells执行的文件.这允许系统管理员为所有用户建立全局缺省环境.
/etc/securetty 
  确认安全终端,即哪个终端允许root登录.一般只列出虚拟控制台,这样就不可能(至少很困难)通过modem或网络闯入系统并得到超级用户特权.
/etc/shells 
  列出可信任的shell.chsh 命令允许用户在本文件指定范围内改变登录shell.提供一台机器FTP服务的服务进程ftpd 检查用户shell是否列在 /etc/shells 文件中,如果不是将不允许该用户登录.
/etc/sysconfig
  网络配置相关目录

------------------------------------------

 

/proc: 目录

档名    文件内容
/proc/cmdline     加载 kernel 时所下达的相关参数!查阅此文件,可了解系统是如何启动的!
/proc/cpuinfo     本机的 CPU 的相关资讯,包含时脉、类型与运算功能等
/proc/devices     这个文件记录了系统各个主要装置的主要装置代号,与 mknod 有关呢!
/proc/filesystems     目前系统已经加载的文件系统罗!
/proc/interrupts     目前系统上面的 IRQ 分配状态。
/proc/ioports     目前系统上面各个装置所配置的 I/O 位址。
/proc/kcore     这个就是内存的大小啦!好大对吧!但是不要读他啦!
/proc/loadavg     还记得 top 以及 uptime 吧?没错!上头的三个平均数值就是记录在此!
/proc/meminfo     使用 free 列出的内存资讯,嘿嘿!在这里也能够查阅到!
/proc/modules     目前我们的 Linux 已经加载的模块列表,也可以想成是驱动程序啦!
/proc/mounts     系统已经挂载的数据,就是用 mount 这个命令呼叫出来的数据啦!
/proc/swaps     到底系统挂加载的内存在哪里?呵呵!使用掉的 partition 就记录在此啦!
/proc/partitions     使用 fdisk -l 会出现目前所有的 partition 吧?在这个文件当中也有纪录喔!
/proc/pci     在 PCI 汇流排上面,每个装置的详细情况!可用 lspci 来查阅!
/proc/uptime     就是用 uptime 的时候,会出现的资讯啦!
/proc/version     核心的版本,就是用 uname -a 显示的内容啦!
/proc/bus/*     一些汇流排的装置,还有 U盘 的装置也记录在此喔!

------------------------------------------

/usr: 目录
  /usr 文件系统经常很大,因为所有程序安装在这里. /usr 里的所有文件一般来自Linux distribution;本地安装的程序和其他东西在/usr/local 下.这样可能在升级新版系统或新distribution时无须重新安装全部程序.
/usr/etc            存放设置文件
/usr/games      存放游戏和教学文件
/usr/include      存放C开发工具的头文件
/usr/share         存放结构独立的数据
/usr/bin 
  几乎所有用户命令.有些命令在/bin 或/usr/local/bin 中.
/usr/sbin 
  根文件系统不必要的系统管理命令,例如多数服务程序. 
/usr/share/man , /usr/share/info , /usr/share/doc  
  手册页、GNU信息文档和各种其他文档文件. 
/usr/include 
  C编程语言的头文件.为了一致性这实际上应该在/usr/lib 下,但传统上支持这个名字.
/usr/lib 
  程序或子系统的不变的数据文件,包括一些site-wide配置文件.名字lib来源于库(library); 编程的原始库存在/usr/lib 里. 
/usr/local 
  本地安装的软件和其他文件放在这里. 
/usr/src             存放程序的源代码


------------------------------------------

/var: 目录
  /var 包括系统一般运行时要改变的数据.每个系统是特定的,即不通过网络与其他计算机共享. 
/var/catman 
  当要求格式化时的man页的cache.man页的源文件一般存在/usr/man/man* 中;有些man页可能有预格式化的版本,存在/usr/man/cat* 中.而其他的man页在第一次看时需要格式化,格式化完的版本存在/var/man 中,这样其他人再看相同的页时就无须等待格式化了. (/var/catman 经常被清除,就象清除临时目录一样.) 
/var/lib 
  系统正常运行时要改变的文件. 
/var/local 
  /usr/local 中安装的程序的可变数据(即系统管理员安装的程序).注意,如果必要,即使本地安装的程序也会使用其他/var 目录,例如/var/lock . 
/var/lock 
  锁定文件.许多程序遵循在/var/lock 中产生一个锁定文件的约定,以支持他们正在使用某个特定的设备或文件.其他程序注意到这个锁定文件,将不试图使用这个设备或文件. 
/var/log 

  各种程序的Log文件,特别是login  (/var/log/wtmp log所有到系统的登录和注销) 和syslog (/var/log/messages 里存储所有核心和系统程序信息. /var/log 里的文件经常不确定地增长,应该定期清除. 
/var/run 

  保存到下次引导前有效的关于系统的信息文件.例如, /var/run/utmp 包含当前登录的用户的信息.
/var/spool 
  mail, news, 打印队列和其他队列工作的目录.每个不同的spool在/var/spool 下有自己的子目录,例如,用户的邮箱在/var/spool/mail 中. 
/var/tmp 

  比/tmp 允许的大或需要存在较长时间的临时文件. (虽然系统管理员可能不允许/var/tmp 有很旧的文件.) 


------------------------------------------


 比较重要的目录

    在 Linux 系统中,有几个目录是特别需要注意的,以下提供几个需要注意的目录,以及预设相关的用途: 
        /etc: 这个目录相当重要,如前所述,你的开机与系统数据文件均在这个目录之下,因此当这个目录被破坏,那你的系统大概也就差不多该死掉了!而在往后的文件中,你 会发现我们常常使用这个目录下的 /etc/rc.d/init.d 这个子目录,因为这个 init.d 子目录是开启一些 Linux 系统服务的 scripts (可以想成是批次檔 )的地方。而在 /etc/rc.d/rc.local 这个文件是开机的执行档。 
        /bin, /sbin, /usr/bin, /usr/sbin: 这是系统预设的执行文件的放置目录,例如 root 常常使用的 userconf, netconf, perl, gcc, c++ 等等的数据都放在这几个目录中,所以如果你在提示字符下找不到某个执行档时,可以在这四个目录中查一查!其中, /bin, /usr/bin 是给系统使用者使用的指令,而 /sbin, /usr/sbin 则是给系统管理员使用的指令!   
        /usr/local: 这是系统预设的让你安装你后来升级的套件的目录。例如,当你发现有更新的 Web 套件(如 Apache )可以安装,而你又不想以 rpm 的方式升级你的套件,则你可以将 apache 这个套件安装在 /usr/local 底下。安装在这里有个好处,因为目前大家的系统都是差不多的,所以如果你的系统要让别人接管的话,也比较容易上手呀!也比较容易找的到数据喔!因此,如果 你有需要的话,通常我都会将 /usr/local/bin 这个路径加到我的 path 中。 
        /home: 这个是系统将有账号的人口的家目录设置的地方。     
        /var: 这个路径就重要了!不论是登入、各类服务的问题发生时的记录、以及常态性的服务记录等等的记录目录,所以当你的系统有问题时,就需要来这个目录记录的文件数据中察看问题的所在啰!而 mail 的预设放置也是在这里,所以他是很重要的     
        /usr/share/man, /usr/local/man: 这两个目录为放置各类套件说明档的地方,例如你如果执行 man man,则系统会自动去找这两个目录下的所有说明文件


文件种类:


谈完了文件格式之后,再来谈谈所谓的文件种类吧!我们在刚刚的属性介绍中提到了最前面的标志 ( d 或 - ) 可以代表目录或文件,那就是不同的文件种类啦!Linux 的文件种类主要有底下

这几种:
    正规文件( regular file ):就是一般类型的文件,在由 ls –al 所显示出来的属性方面,第一个属性为 [ - ]。另外,依照文件的内容,又大略可以分为两种文件种类:
        纯文字文件(ascii) :这是 Unix 系统中最多的一种啰,几乎只要我们可以用来做为设定的文件都属于这一种;
        二进制文件(binary) :通常执行档除了 scripts (文字型批次文件)之外,就是这一种文件格式;  
    目录 (directory):就是目录!第一个属性为 [ d ];
    连结档 (link):就是类似 Windows 底下的快捷方式啦!第一个属性为 [ l ];
    设备档 (device):与系统周边相关的一些文件,通常都集中在 /dev 这个目录之下!通常又分为两种:
    区块 (block) 设备档 :就是一些储存数据,以提供系统存取的接口设备,简单的说就是硬盘啦!例如你的一号硬盘的代码是 /dev/hda1 等等的文件啦!第一个属性为 [ b ];
    字符 (character) 设备档 :亦即是一些串行端口的接口设备,例如键盘、鼠标等等!第一个属性为 [ c ]。


Linux 的文件系统( inode ):
 

在 Linux 系统当中,每个文件不止有文件的内容数据,还包括文件的种种属性,例如:所属群组、所属使用者、能否执行、文

件建立时间、文件特殊属性等等。我们将每个文件的内容分为两个部分来储存,一个是文件的属性,另一个则是文件的内容。
 
为了应付这两个不同的咚咚,所以 ext2 规划出 inode 与 Block 来分别储存文件的属性( 放在 inode 当中 )与文件的内容( 放置在 Block area 当中 )。当我们要将一个 partition 格式化

( format )为 ext2 时,就必须要指定 inode 与 Block 的大小才行,也就是说,当 partition 被格式化为 ext2 的文件系统时,他一定会有 inode table 与 block area 这两个区域。
 
Block 已经在前面说过了,他是数据储存的最小单位。那么 inode 是什么?!简单的说, Block 是记录『文件内容数据』的区域,至于 inode 则是记录『该文件的相关属性,以及文件内容

放置在哪一个 Block 之内』的信息。简单的说, inode 除了记录文件的属性外,同时还必须要具有指向( pointer )的功能,亦即指向文件内容放置的区块之中,好让操作系统可以正确的去

取得文件的内容啊

    该文件的拥有者与群组(owner/group);
    该文件的存取模式;
    该文件的类型;
    该文件的建立日期(ctime)、最近一次的读取时间(atime)、最近修改的时间 (mtime);
    该文件的容量;
    定义文件特性的旗标(flag),如 SetUID...;
    该文件真正内容的指向 (pointer);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488896&siteId=291194637