一点一滴学Linux

    返回首页    发表留言
本文作者:李德强
          第三节 系统目录
 
 

        Linux是采用的树型目录结构,每个发行版的目录结构都不尽相同,但大体上没有太大的差别。我们从Fedora21入手来学习Linux的系统目录。在终端中进入根目录并查看其下的子目录:

cd /
ls -hl
total 72K
lrwxrwxrwx.   1 root      root         7 Nov 18 20:33 bin -> usr/bin
dr-xr-xr-x.   6 root      root      4.0K Mar 12 18:40 boot
drwxr-xr-x.  22 root      root      3.6K Mar 30 08:38 dev
drwxr-xr-x. 180 root      root       12K Mar 30 08:36 etc
drwxr-xr-x.   5 root      root      4.0K Jan 20 18:00 home
lrwxrwxrwx.   1 root      root         7 Nov 18 20:33 lib -> usr/lib
lrwxrwxrwx.   1 root      root         9 Nov 18 20:33 lib64 -> usr/lib64
drwx------.   2 root      root       16K Dec  4 04:28 lost+found
drwxr-xr-x.   2 root      root      4.0K Mar 13 09:22 media
drwxr-xr-x.   2 root      root      4.0K Nov 18 20:33 mnt
drwxr-xr-x.   8 root      root      4.0K Jan 20 09:50 opt
dr-xr-xr-x. 222 root      root         0 Mar 30  2015 proc
dr-xr-x---.  10 root      root      4.0K Mar 27 11:00 root
drwxr-xr-x.  52 root      root      1.6K Mar 30 08:38 run
lrwxrwxrwx.   1 root      root         8 Nov 18 20:33 sbin -> usr/sbin
drwxr-xr-x.   2 root      root      4.0K Nov 18 20:33 srv
dr-xr-xr-x.  13 root      root         0 Mar 30 08:36 sys
drwxrwxrwt.  21 root      root       520 Mar 30 09:14 tmp
drwxr-xr-x.  13 root      root      4.0K Dec 19 11:28 usr
drwxr-xr-x.  21 root      root      4.0K Mar 30  2015 var

        可以看到/bin、/lib、lib64、/sbin是/usr下的子目录链接。下面我们来一个个的学习这些目录的作用。

一、/boot

        在boot目录下执行:

ls -hl
total 121M
-rw-r--r--. 1 root root 143K Nov 28 03:14 config-3.17.4-301.fc21.x86_64
drwxr-xr-x. 6 root root 4.0K Mar 12 18:40 grub2
-rw-r--r--. 1 root root  19M Mar 12 18:40 initramfs-3.18.8-201.fc21.x86_64.img
-rw-r--r--. 1 root root 551K Dec  4 04:39 initrd-plymouth.img
-rw-r--r--. 1 root root 179K Oct 21 18:08 memtest86+-5.01
-rw-------. 1 root root 2.9M Feb 28 02:24 System.map-3.18.8-201.fc21.x86_64
-rwxr-xr-x. 1 root root 5.6M Feb 28 02:24 vmlinuz-3.18.8-201.fc21.x86_64

        config为系统内核的配置文件。

        grub2是一个文件夹,存放这grub2的系统引导程序。

        initrd是系统启动时需要的系统模块。

        System.map是系统内核的变量对应表。

        vmlinuz这个文件就是Linux的内核文件。

二、/dev

        /dev目录下存放的Linux系统可识别的所有设备。常用设备有存储设备、显示设备、输入设备等,在dev目录下可以看到

agpgart          lp3                 tty0   tty42    usbmon3
autofs           mapper              tty1   tty43    usbmon4
block            mcelog              tty10  tty44    usbmon5
bsg              mem                 tty11  tty45    vboxdrv
btrfs-control    memory_bandwidth    tty12  tty46    vboxdrvu
bus              mqueue              tty13  tty47    vboxnetctl
char             net                 tty14  tty48    vboxusb
console          network_latency     tty15  tty49    vcs
core             network_throughput  tty16  tty5     vcs1
cpu              null                tty17  tty50    vcs2
cpu_dma_latency  nvram               tty18  tty51    vcs3
cuse             parport0            tty19  tty52    vcs4
disk             port                tty2   tty53    vcs5
dm-0             ppp                 tty20  tty54    vcs6
dm-1             ptmx                tty21  tty55    vcsa
dm-2             pts                 tty22  tty56    vcsa1
dri              random              tty23  tty57    vcsa2
fb0              raw                 tty24  tty58    vcsa3
fd               rfkill              tty25  tty59    vcsa4
fedora           rtc                 tty26  tty6     vcsa5
fedora00         rtc0                tty27  tty60    vcsa6
full             sda                 tty28  tty61    vfio
fuse             sda1                tty29  tty62    vga_arbiter
hidraw0          sda2                tty3   tty63    vhci
hidraw1          sda3                tty30  tty7     vhost-net
hidraw2          sda5                tty31  tty8     vmci
hpet             sda6                tty32  tty9     vmmon
hugepages        sda7                tty33  ttyS0    vmnet0
initctl          sda8                tty34  ttyS1    vmnet1
input            sg0                 tty35  ttyS2    vmnet8
kmsg             shm                 tty36  ttyS3    vsock
kvm              snapshot            tty37  uhid     watchdog
log              snd                 tty38  uinput   watchdog0
loop-control     stderr              tty39  urandom  zero
lp0              stdin               tty4   usbmon0
lp1              stdout              tty40  usbmon1
lp2              tty                 tty41  usbmon2

        可用设备很多对于初学者来说不需要全部掌握,只需要了解一些常用的设备即可。比如:

  • IDE硬盘hda、hda1、hda2、hdb、hdb1、hdb2等。

  • stat硬盘sda、sda1、sda2、sdb、sdb1、sdb2等。

  • 光驱设备cdrom。

  • 终端设备tty、tty0、tty1、tty2。

  • 常零设备zero。

  • 空设备null。

三、/etc

        /etc文件夹可谓是Linux下最重要的目录之一,它下面存放了大量的系统配置文件和大量的软件包的配置文件。etc下的配置文件非常之多,我们先从简单的入手,来学习Linux的配置文件:

  • hostname:计算机名称。

  • hosts:本地域名解析配置文件。基格式为IP地址,计算机名、域名。

  • localtime:本地时间,这是一个软链接文件localtime -> /usr/share/zoneinfo/Asia/Shanghai上海时间。

  • locale.conf:本地语言,里面默认值为LANG="en_US.UTF-8"。

  • profile:自动运行脚本,在用户登录是自动运行,为用户设置相关的工作环境。

  • sysconfig/iptables:iptables防火墙配置。

  • sysconfig/network-script/ifcfg-eth0:以太网设备配置。

四、/home

        /home目录里存放了除root用户外其它用户的主目录(除特殊指定的主目录外)。比如系统中有3个用户分别为lidq、guest、git。如果为他们分配默认的主目录,系统就会在/home目录下创建3个名为lidq、guest、git的文件夹。

五、/media

        系统自动挂载可移动设备的目录。


 

六、/mnt

        为系统管理员提供一个可以手动挂载设备的挂载点。

七、/opt

        为系统软件包提供额外安装目录。

八、/proc

        系统核心与执行程序的一些信息。

  • /proc/cpuinfo:关于处理器的信息,如类型、厂家、型号和性能等。

  • /proc/devices:当前运行内核所配置的所有设备清单。

  • /proc/dma:当前正在使用的DMA通道。/proc/filesystems 当前运行内核所配置的文件系统。

  • /proc/interrupts:正在使用的中断,和曾经有多少个中断。

  • /proc/ioports:当前正在使用的I/O端口。

九、/root

        超级用户root的主目录。

十、/usr

        这也是Linux的最重要目录之一,里面含有相当多的系统信息,内有许多目录,用来存放程序与指令等等。

  • /usr/bin:放置可执行程序。

  • /usr/include:软件包的头文件包含目录。

  • /usr/lib:Linux的动态链接库。

  • /usr/local:本地软件包安装重定向位置。

  • /usr/local/bin:本地软件包安装重定向位置的可执行程序。

  • /usr/sbin:存放管理者使用程序。

  • /usr/src:存放内核代码。


 

十一、/var

  • /var:包括系统一般运行时要改变的数据。

  • /var/lib:系统正常运行时要改变的文件。

  • /var/local:/usr/local中安装的程序的可变数据。

  • /var/lock:锁定文件。

  • /var/log:各种程序的Log文件。

  • /var/run:保存到下次引导前有效的关于系统的信息文件。

  • /var/spool:mail, news, 打印队列和其他队列工作的目录。

  • /var/tmp:比/tmp 允许的大或需要存在较长时间的临时文件。

    返回首页    返回顶部
  看不清?点击刷新

 

  Copyright © 2015-2023 问渠网 辽ICP备15013245号