<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">下的文件系统为树形结构,入口为</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/</span> 树形结构下的文件目录: 无论哪个版本的<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">系统,都有这些目录,这些目录应该是标准的。各个</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">发行版本会存在一些小小的差异,但总体来说,还是大体差不多。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>1. /</strong></span></span> 文件系统的入口,<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">最高一级目录</span>; </span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>2. /bin</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">基础系统所需要的命令位于此目录</span>,是最小系统所需要的命令,如:</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">ls, cp, mkdir</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等。 这个目录中的文件都是可执行的,一般的用户都可以使用。 </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>3. /boot</strong></span></span> 包含<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">Linux</span></span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">内核及系统引导程序所需要的文件</span>,比如 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">vmlinuz initrd.img </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件都位于这个目录中。在一般情况下,</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">GRUB</span></span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">或<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">LILO</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">系统引导管理器</span>也位于这个目录;</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>4. /dev</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">设备文件存储目录</span>,比如声卡、磁盘</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">... ...</span> 这是一个非常有趣的目录,是<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统的一个闪亮的特性 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">- </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">所有对象都是文件或目录</span>。仔细观察这个目录你会发现</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">hda1, hda2</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">, </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">它们代表系统主硬盘的不同分区。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/dev/cdrom</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">和</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/dev/fd0</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">代表你的</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">CDROM</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">驱动器和</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">floppy</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">驱动器。看上去可能有些奇怪,但比较文件和硬件的特性这却是十分合理的。它们都可以读出和写入。例如</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/dev/dsp</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">,这个文件代表你的扬声器。那么写入这个文件的数据都回传送到喇叭。试一试 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">'cat /etc/lilo.conf > /dev/dsp' </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">你会听到一些声音。这是你的 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">lilo.conf </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件的声音!同样,向 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/dev/ttyS0 ( COM 1 ) </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">读出或写入数据你可以和接到上面的设备进行通讯。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>5. /etc</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">存放系统程序或者一般工具的配置文件</span>。 如安装了</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">apache2</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">之后,配置文件在</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/etc/apache2/</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录下。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/etc/init.d </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这个目录是用来存放系统或服务器以</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">System V</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">模式启动的脚本,这在以</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">System V</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">模式启动或初始化的系统中常见。 如</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(125, 166, 71); background-position: 0% 50%; background-repeat: repeat repeat;">apache2</span></span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(125, 166, 71); background-position: 0% 50%; background-repeat: repeat repeat;">的<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">/etc/init.d apache2 start|stop|restart</span></span></span> <span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(125, 166, 71); background-position: 0% 50%; background-repeat: repeat repeat;">MySQL</span></span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(125, 166, 71); background-position: 0% 50%; background-repeat: repeat repeat;">为<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">/etc/init.d mysql start|stop|restart</span></span></span>
<span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>6. /home</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">普通用户默认存放目录</span></span> <span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">是多用户环境,所以每一个用户都有一个只有自己可以访问的目录(当然管理员也可以访问)。它们以 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/home/username </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的方式存在。这个目录也保存一些应用对于这个用户的配置,比如 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">IRC, X </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="color:#C90016;word-wrap: normal; word-break: normal;"><strong>7. /lib</strong></span> </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">库文件存放目录</span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">这里包含了系统程序所需要的所有共享库文件</span>,类似于 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Windows </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的共享库</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">DLL </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件。 </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>8. /lost+found</strong></span></span> 在<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">ext2</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">ext3</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统中,<span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">当系统意外崩溃或机器意外关机,而产生一些文件碎片放在这里</span>。当系统启动的过程中</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">fsck</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">工具会检查这里,并修复已经损坏的文件系统。 有时系统发生问题,有很多的文件被移到这个目录中,可能会用手工的方式来修复,或移到文件到原来的位置上。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">应该正确的关机。但有时你的系统也可能崩溃掉或突然断电使系统意外关机。那么启动的时候 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">fsck</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">将会进行长时间的文件系统检查。</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Fsck </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">会检测并试图恢复所发现的不正确的文件。被恢复的文件会放置在这个目录中。所恢复的文件也许并不完整或并不合理,但毕竟提供了一些恢复数据的机会。 </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>9. /media </strong></span></span>即插即用型<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">存储设备的挂载点</span>自动在这个目录下创建,比如</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">USB</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">盘系统自动挂载后,会在这个目录下产生一个目录 ;</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">CDROM/DVD</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">自动挂载后,也会在这个目录中创建一个目录,类似</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">cdrom </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的目录。这个只有在最新的发行套件上才有</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">.</span>
<span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>10. /mnt</strong></span></span> <span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/mnt </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这个目录一般是用于存放挂载储存设备的挂载目录的,比如有</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">cdrom </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等目录。有时我们可以把让系统开机自动挂载文件系统,把挂载点放在这里也是可以的。比如光驱可以挂载到</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/mnt/cdrom </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">。 这是一个普通的加载目录,在这里你可以加载你的文件系统或设备。 加载是使一个文件系统对于系统可用的过程。 在加载后你的文件可以在加载目录下访问。 这个目录通常包含加载目录或用于加载软驱和光驱的子目录。 如果需要,你也可以在这里建立其它的加载目录。 对于加载目录的位置并没有强制性的要求,你可以在系统的任意位置建立加载目录。 建立 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/mnt </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">只是为了使系统更工整的惯例。 </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>11. /opt </strong></span></span>表示的是可选择的意思,<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">有些软件包也会被安装在这里,也就是自定义软件包</span>,比如在</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Fedora Core 5.0</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">中,</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">OpenOffice</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">就是安装在这里。<span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">有些我们自己编译的软件包,就可以安装在这个目录中</span>;通过源码包安装的软件,可以通过 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">./configure --prefix=/opt/</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">,将软件安装到</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">opt</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录。 这个目录包含所有默认系统安装之外的软件和添加的包。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>12. /proc</strong></span></span> 操作系统运行时,进程(正在运行中的程序)信息及内核信息(比如<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">cpu</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">、硬盘分区、内存信息等)存放在这里。</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/proc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录是伪装的文件系统</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">proc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的挂载目录,</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">proc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">并不是真正的文件系统。 这是系统中极为特殊的一个目录,实际上任何分区上都不存在这个目录。它实际是个实时的、驻留在内存中的文件系统。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>13. /root </strong></span></span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">超级权限用户</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">root</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的家目录;</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>14. /sbin </strong></span></span>大多是涉及<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">系统管理的命令的存放,是超级权限用户<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">root</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">的可执行命令存放地</span>,普通用户无权限执行这个目录下的命令; 这个目录和 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/sbin; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/X11R6/sbin</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/local/sbin</span> 目录是相似的; 我们记住就行了,凡是目录<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">sbin</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">中包含的都是</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">root</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">权限才能执行的。</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>15. /tmp</strong></span></span> 临时文件目录,有时用户运行程序的时候,会产生临时文件。 <span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/tmp</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">就用来存放临时文件的。</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/tmp</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录和这个目录相似。 许多程序在这里建立</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">lock</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件和存储临时数据。有些系统会在启动或关机时清空此目录。 </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>16. /usr</strong></span></span> 这个是<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">系统存放程序的目录</span>,比如命令、帮助文件等。 这个目录下有很多的文件和目录。 当我们安装<span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">一个<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">发行版官方提供的软件包时,大多安装在这里</span>。 如果有涉及服务器配置文件的,会把配置文件安装在</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/etc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录中。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录下包括: 涉及字体目录</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/fonts </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">, 帮助目录 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/man</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/doc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">, 普通用户可执行文件目录</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/bin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/local/bin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/X11R6/bin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">, 超级权限用户</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">root</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的可执行命令存放目录,比如 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/sbin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/X11R6/sbin</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/local/sbin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等; 还有程序的头文件存放目录</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/include</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/bin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这个目录是可执行程序的目录,普通用户就有权限执行; 当我们从系统自带的软件包安装一个程序时,他的可执行文件大多会放在这个目录。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/sbin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这个目录也是可执行程序的目录,但大多存放涉及系统管理的命令。只有</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">root</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">权限才能执行;相似目录是</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/sbin </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/local/sbin</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">或</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/X11R6/sbin</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">等; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/local </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这个目录一般是用来存放用户自编译安装软件的存放目录;一般是通过源码包安装的软件,如果没有特别指定安装目录的话,一般是安装在这个目录中。这个目录下面有子目录。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/lib </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">和</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/lib </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录相似,是库文件的存储目录; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">系统共用的东西存放地,比如 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/fonts </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">是字体目录,是用户都共用的吧。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/doc</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">和</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/share/man</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">帮助文件,也是共用的吧; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/src </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">是内核源码存放的目录,比如下面有内核源码目录,比如 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">linux </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">、</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">linux-2.xxx.xx </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录等。有的系统也会把源码软件包安装在这里。比如</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Fedora/Redhat</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">,当我们安装</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">file.src.rpm</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的时候,这些软件包会安装在 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/src/redhat</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">相应的目录中。请参考: 《</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">file.src.rpm </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">使用方法的简单介绍》 。另外</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Fedhat 4.0 5.0</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">,他的内核源码包的目录位于</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr/src/kernels</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录下的某个目录中(只有安装后才会生成相应目录); </span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>17. /var</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;">这个目录的内容是经常变动的</span>,看名字就知道,我们可以理解为</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">vary</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的缩写,</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">下有</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/log </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">这是用来存放系统日志的目录。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/www</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">目录是定义</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Apache</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">服务器站点存放目录;</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/lib </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">用来存放一些库文件,比如</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">MySQL</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的,以及</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">MySQL</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">数据库的的存放地; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/log </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">系统日志存放,分析日志要看这个目录的东西; </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/var/spool </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">打印机、邮件、代理服务器等假脱机目录;</span>
<span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"></span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; line-height: 30px; font-size: 15pt;"><strong>Windows</strong></span></span><span style="word-wrap: normal; word-break: normal; line-height: 30px; font-size: 15pt;"><strong>和</strong></span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;"><span style="word-wrap: normal; word-break: normal; line-height: 30px; font-size: 15pt;"><strong>Linux</strong></span></span><span style="word-wrap: normal; word-break: normal; line-height: 30px; font-size: 15pt;"><strong>文件系统的区别</strong></span>
<span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统与</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Windows</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统有很大的差别。 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统作为开端,只有一个单独的顶级目录结构。所有一切都从 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">'</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">根</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">' </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">开始,用 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">'/' </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">代表</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">, </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">并且延伸到子目录。</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">DOS/Windows</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">有不同的分区,同时目录都存于分区上。</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">则通过 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">'</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">加载</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">' </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的方式把所有分区都放置在 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">'</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">根</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">' </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">下制定的目录里。 </span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;"><strong>一句话总结:</strong><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>Windows</strong></span></span></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;"><strong>下,目录结构属于分区;</strong><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>Linux</strong></span></span></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;"><strong>下,分区 </strong><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>'</strong></span></span></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;"><strong>加载</strong><span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;"><strong>' </strong></span></span></span><span style="font-size:14px;color:#C90016;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(255, 255, 0); background-position: 0% 50%; background-repeat: repeat repeat;"><strong>于目录结构。</strong></span></span> <span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;"><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(153, 204, 255); background-position: 0% 50%; background-repeat: repeat repeat;">在<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">Windows</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(153, 204, 255); background-position: 0% 50%; background-repeat: repeat repeat;">下<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">, </span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(153, 204, 255); background-position: 0% 50%; background-repeat: repeat repeat;">启动时检测不同的分区并被赋予一个分区字母</span>。<span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(230, 230, 76); background-position: 0% 50%; background-repeat: repeat repeat;">在<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(230, 230, 76); background-position: 0% 50%; background-repeat: repeat repeat;">下除非你加载一个分区或设备<span style="font-family:Nimbus Mono L, Courier New, monospace;word-wrap: normal; word-break: normal; line-height: 24px;">,</span></span><span style="word-wrap: normal; word-break: normal; background-image: none; background-attachment: scroll; background-color: rgb(230, 230, 76); background-position: 0% 50%; background-repeat: repeat repeat;">否则系统不会知道那个分区的存在</span>。这看上去也许不是访问分区或设备的最方便的方式,但是这种方式提供了伟大的机动性。 这种构建的方式被称为统一的文件系统,超越了</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Windows</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">所使用的方式。举个使用 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">/usr </span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">的例子。这个目录包含了大多数的系统可执行文件。在</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Linux</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">文件系统下,你可以选择把它加载为其他分区甚至网络上的其他计算机。系统不会感知其中的不同,因为它表现出的只是本地目录结构下众多的目录中的一个而已。你是否有妄图在</span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">Windows</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">下移动可执行文件和数据,而得到的是不得不去修改注册表或干脆蓝屏?你可曾奢望过移动 </span><span style="font-family:Nimbus Mono L, Courier New, monospace;font-size:14px;word-wrap: normal; word-break: normal; line-height: 24px;">C:</span><span style="font-size:14px;word-wrap: normal; word-break: normal; line-height: 19px;">到其他分区上?</span>
<a target=_blank name="zoom7" style="line-height: 24px; background-color: rgb(220, 236, 204); font-family: simsun; text-decoration: underline; color: rgb(89, 145, 0);"></a><span style="line-height: 24px; font-family: simsun; "><strong>存储设备进行格式化(即建立文件系统)</strong></span>
1。关于文件系统
对存储设备分区还是不够的,我们还要对新增分区进行格式化;一个分区只有建立了某种
文件系统后,这个分区才能使用;建立文件系统过程,就是用相应格式化工具格式化分区的过程,这个过程和我们在Windows中格式化某个分区为NTFS分
区类似;没有什么高深的内容,只是所用的工具不一样罢了;
Linux操作系统中,几乎支持目前主流的文件系统,比如NTFS(只读)、FAT(可读可写)、ext2、ext3、reiserfs、hfs
(MAC 操作系统的文件系统)、swap 交换分区...
... 还有一些咱们不熟悉的操作系统的文件系统等;
在Linux中,我们常用的文件系统无非是上面例出的这些;如果您新增了一个硬盘,可能想格
式化成 Linux的文件系统,最佳选择是 reiserfs 或ext3;目前ext2已被 ext3取代;我们不推荐用ext2文件系统,ext2的使用风险比较大;速度最快的文件系统,当属reiserfs;reiserfs 还有很多优点,比如更安全;ext3是Redhat认为最好的文件系统。
相对来说reiserfs还是比ext3要优秀。
文件系统概念
1。*nix系统中:一切皆文件;
2。文件
a. )文件的成分: 无论文件是一个程序、一个文档、一个数据库,或者是一个目录,操作系统都会赋予它如下所示的同样的结构:
◆索引节点 又称I节点,在文件系统结构中,包含有关相应文件的信息的一个记录,这些信息包括文件权限、文件主、文件大小、存放位置、建立日期等。
◆数据 文件的实际内容,它可以是空的,也可以非常大,并且有自己的结构。
b.) Linux系统区分文件名的大小写
以圆点“.”开头的文件名是隐含文件(dot
files),默认方式下使用ls命令并不能把它们在屏幕上显示出来。同样,在默认情况下,Shell通配符并不匹配这类文件名。
c.) 文件名通配符
星号(*): 与0个或多个任意的字符相匹配
问号(?): 问号只与一个任意的字符匹配,可以使用多个问号
方括号([
]) : 与问号相似,只与一个字符匹配。它们的区别在于,问号与任意一个字符匹配,而方括号只与括号中列出的字符之一匹配。例如letter
[123]只与文件letter1、letter2或letter3匹配,但不与文件 letter12匹配。可以用短横线代表一个范围内的字符,而不用将它们一一列出。例如,letter[1-3]是letter[123]的简写形式。但
是,要注意范围内的字符都按升序排列,即[A-Z]是有效的,而[Z-A]是无效的。方括号中可以列出多个范围,如[A-Za-z]可以和任意大写或小写
的字符相匹配。方括号中如果以惊叹号“!”开始,表示不与惊叹号后的字符匹配。
文件类型
Linux操作系统支持普通文件、目录文件、特别文件及符号链接文件等文件类型。
1. 普通文件
普通文件也称作常规文件,包含各种长度的字节串。核心对这些数据没有进行结构化,只是作为有序的字节序列把它提交给应用程序。应用程序自己组织和解释这些数据,通常把它们归并为下述类型之一:
◆文本文件,由ASCII字符构成。例如,信件、报告和称作脚本(Script)的命令文本文件,后者由shell解释执行。
◆数据文件,由来自应用程序的数字型和文本型数据构成。例如,电子表格、数据库,以及字处理文档。
◆可执行的二进制程序,由机器指令和数据构成。例如,上面所说的系统提供的命令。
使用file命令可以确定指定文件的类型。该命令可以将任意多个文件名当做参数,其一般使用格式是:file 文件名 [文件名...]
2. 目录
目录是一类特殊的文件,利用它可以构成文件系统的分层树型结构。如同普通文件那样,目录文件也包含数据;但目录文件与普通文件的差别是,核心对这些数据加以结构化,它是由成对的“I节点号/文件名”构成的列表。
◆I节点号是检索I节点表的下标,I节点中存放有文件的状态信息。
◆文件名是给一个文件分配的文本形式的字符串,用来标识该文件。在一个指定的目录中,任何两项都不能有同样的名字。
每个目录的第一项都表示目录本身,并以“.”作为它的文件名。每个目录的第二项的名字是“..”,表示该目录的父目录。
应注意:以“.”开头的文件名表示隐含文件,使用带-a选项的ls命令可以列出它们。
当把文件添加到一个目录中的时候,该目录的大小会增长,以便容纳新文件名。当删除文件时,目录的尺寸并不减少,而是核心对该目录项做上特殊标记,以便下次添加一个文件时重新使用它。ls命令不会列出这些未被使用的项。
Linux系统的目录结构
Linux文件系统采用带链接的树形目录结构,即只有一个根目录(通常用“/”表示),其中含有下级子目录或文件的信息;子目录中又可含有更下级的子目录或者文件的信息。这样一层一层地延伸下去,构成一棵倒置的树,如图1所示。
图1 Linux树型目录结构
在目录树中,根节点和中间节点(用圆圈表示)都必须是目录,而普通文件和特别文件只能作为“叶子”出现。当然,目录也可以作为叶子。
(1)用户主目录
当注册进入系统时,主目录就是当前工作目录。主目录往往位于/home目录之下,并且与注册名相同,例如,/home/mengqc。通常主目录包含子目录、数据文件,以及用于注册环境的配置文件。
- 绝对路径和相对路径
什么情况下使用绝对路径名,什
么情况下使用相对路径名,取决于哪种方式涉及到的目录更少。路径短,不仅键盘输入少,而且节省系统搜索路径的时间,提高执行效率。例如,当前的工作目录是 /etc/conf/cf.d,如果需要访问系统口令文件/etc/passwd,那么使用绝对路径名是/etc/passwd,使用相对路径名是..
/../passwd。绝对路径名/etc/passwd涉及的目录有2个,而相对路径名../../passwd涉及的目录却是3个。此时,使用绝对路
径名更有效。
但是,如果当前工作目录是/home/mengqc/lib,要访问在 func目录之下的file1文件,那么使用绝对路径名是/home/mengqc/lib/func/file1,使用相对路径名是 func/file1。绝对路径名/home/mengqc/lib/func/file1涉及的目录有5个,而相对路径名涉及的目录只有2个。此时,使
用相对路径名更有效。
如果不清楚当前工作目录与其它目录之间的关系,那么最好使用绝对路径名。
3. 设备文件
在Linux系统中,所有设备都作为一类特别文件对待,用户像使用普通文件那样对设备进行操作,从而实现设备无关性。但是,设备文件除了存放在文件I节点中的信息外,它们不包含任何数据。系统利用它们来标识各个设备驱动器,核心使用它们与硬件设备通信。
有两类特别设备文件,它们对应不同类型的设备驱动器:
◆字符设备 最常用的设备类型,允许I/O传送任意大小的数据,取决于设备本身的容量。使用这种接口的设备包括终端、打印机及鼠标。
◆块设备 这类设备利用核心缓冲区的自动缓存机制,缓冲区进行I/O传送总是以1KB为单位。使用这种接口的设备包括硬盘、软盘和RAM盘。
Linux系统的文件系统路径
1。路径分为绝对路径和相对路径。
绝对路径是从/(也被称为根目录)开始的,比如/usr、/etc/X11。如果一个路径是从/开始的,它一定是绝对路径。
相对路径是以 . 或 .. 开始的,.表示用户当前操作所处的位置,而.. 表示上级目录;在路径中,.表示用户当前所处的目录,而..上级目录,要把.和..当做目录来看。
2。[[email protected]
~]# pwd 注:判断用户当前所处的位置,也就是说他到底位于哪?
use when you are lost.
3。
[[email protected] ~]# cd . 注:我们进入。
[[email protected] ~]# cd .. 注:我们切入/root的上级目录。
注意,cd之后有个空格。
4。~ 表示当前用户自己的家目录;
~USER 表示用户名为USER的家目录
如:
cd ~ 回到当前用户的家目录;
cd ~USERNAME 回到USERNAME用户的家目录;
文件系统及其安装
一个硬盘上可以同时存在多个文件系统,每个文件系统占据硬盘的一个独立分 区。Linux文件系统可以根据需要随时装卸,从而实现文件存储空间的动态扩充和信息安全。在系统初启时,往往只有一个文件系统被安装上,即根文件系统,
其上的文件主要是保证系统正常运行的操作系统的代码文件,以及若干语言编译程序、命令解释程序和相应的命令处理程序等构成的文件,此外,还有大量的用户文 件空间。根文件系统一旦安装上,则在整个系统运行过程中是不能卸下的,它是系统的基本部分。
其它的文件系统(例如,由软盘构成的文件系统)可以根据需要(如从硬盘向软盘复制文件),作为子系统动态地安装到主系统中,如图5所示。其中,mnt是为安装子文件系统而特设的安装节点。
图5 文件系统安装
经过安装之后,主文件系统与子文件系统就构成一个有完整目录层次结构的、容量更大的文件系统。这种安装可以高达几级。就是说,若干子文件系统可以并列安装到主文件系统上,也可以一个接一个地串连安装到主文件系统上。
已安装的子文件系统也可从整个文件系统上卸下来,恢复安装前的独立状态。
1.建立文件系统
当硬盘完成分区后,应该在该分区上建立文件系统。这一步工作是通过mkfs工具来完成的。例如,如果需要在分区/dev/hda1上建立ext2文件系统,并检查坏块,应该使用以下命令:
# mkfs -c /dev/hda1
注意,只有root用户才能建立或安装/卸下文件系统。
2.安装文件系统
创建文件系统后,需要使用命令mount将该文件系统安装到主文件系统中。命令mount有三个主要参数:
◆需要安装的文件系统类型,用“-t
fstype”选项来指定,这与mkfs中的-t选项是一样的。
◆所需访问的文件系统所在分区名,通常是位于目录/dev中的特别设备文件;如果需要安装网络文件系统时,就使用该服务器上输出的目录名。
◆ 安装新文件系统的路径名,也就是放置新文件系统的安装点(Mount
Point)。通常这是一个空目录名,并且是专门为安装新文件系统而准备的。在Linux系统下,目录/mnt是常用的文件系统安装目录,缺省情况下, CDROM和软盘驱动器都分别安装在其子目录下。当然,文件系统也可以被安装到其它空目录中。例如,需要将MSDOS文件系统分区/dev/hda1安装
到系统的空目录/dos中,应该使用以下命令:
# mount -t msdos /dev/hda1 /dos
3.卸载文件系统
在关闭系统之前,为了保证文件系统的完整 性,所有安装的文件系统都必须被卸载。通常在/etc/fstab文件中定义的文件系统都