一、Linux目錄結(jié)構(gòu) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
rootfs:根文件系統(tǒng),根是"/"。
1、/boot
系統(tǒng)啟動(dòng)相關(guān)的文件,如內(nèi)核、intrd、以及grub(bootloader)
root@hao:~# ls / boot abi - 3.2 . 0 - 29 -generic-pae grub memtest86+.bin System.map- 3.2 . 0 - 29 -generic- pae config - 3.2 . 0 - 29 -generic-pae initrd.img- 3.2 . 0 - 29 -generic-pae memtest86+_multiboot.bin vmlinuz- 3.2 . 0 - 29 -generic-pae
2、/dev
設(shè)備文件。所有的硬件都被識(shí)別為文件,比如插入一個(gè)U盤,也會(huì)在dev目錄下創(chuàng)建一個(gè)文件,如下圖。顯示為青色的是符號(hào)鏈接文件,黃色為特殊文件,作為設(shè)備的訪問入口存在。設(shè)備文件分為塊設(shè)備和字符設(shè)備,塊設(shè)備可以隨機(jī)訪問,按數(shù)據(jù)塊訪問。字符設(shè)備線性訪問,字符為單位,比如顯示器和鼠標(biāo)。
3、/etc
配置文件。系統(tǒng)中所有的程序的配置文件都在該目錄或其子目錄下。因此,這里的文件大多是純文本格式。
4、/home
用戶家目錄。默認(rèn)為home下的跟用戶名同名的目錄,如
root@hao:~# ls / home hao
5、/root
root用戶家目錄。直接在根目錄下,而不是在home下。
6、/lib
庫文件及內(nèi)核模塊文件目錄。庫文件分為靜態(tài)庫.a和動(dòng)態(tài)庫.so(shared object 共享對(duì)象)兩種。庫是被調(diào)用的封裝好的功能,在系統(tǒng)上執(zhí)行時(shí),共享庫載入內(nèi)存時(shí),一份存儲(chǔ),多個(gè)程序使用。而靜態(tài)庫,直接鏈接到程序的地址空間并且作為程序的一部分存在。內(nèi)核模塊文件:/lib/modules。綠顏色,表示有執(zhí)行權(quán)限。
7、/media
掛載點(diǎn)目錄。把某個(gè)設(shè)備與某個(gè)目錄建立關(guān)系就叫做掛載。media 用于掛載移動(dòng)設(shè)備
8、/mnt
掛載點(diǎn)目錄。掛載額外的臨時(shí)文件系統(tǒng)。
9、/misc
雜項(xiàng)
10、/opt
可選目錄。第三方程序的安裝目錄。現(xiàn)在通常放在/usr/local
11、/proc
偽文件系統(tǒng)。系統(tǒng)未啟動(dòng)時(shí),沒有任何內(nèi)容,其實(shí)為空。系統(tǒng)啟動(dòng)后便不為空,為內(nèi)核映像文件,保存內(nèi)核的可調(diào)參數(shù)和內(nèi)核工作的統(tǒng)計(jì)數(shù)據(jù),系統(tǒng)調(diào)優(yōu)和性能監(jiān)控都與其相關(guān)。
12、/sys
? 偽文件系統(tǒng)。跟硬件設(shè)備相關(guān)的屬性映射文件,修改磁盤調(diào)度隊(duì)列時(shí)與其相關(guān)。
13、/tmp
臨時(shí)文件目錄。一般每個(gè)月會(huì)清除。每個(gè)用戶都可創(chuàng)建,僅可刪除自己創(chuàng)建的文件。
14、/var
可變化的文件目錄。
15、/bin(binary)
用戶命令。可執(zhí)行文件。系統(tǒng)啟動(dòng)時(shí)需要的執(zhí)行文件(二進(jìn)制)
16、/sbin
管理命令。
17、/usr(Universal shared Read-Only)
只讀文件。
/usr/(s)bin不同于/bin,這里的命令為了正常提供基本功能,與系統(tǒng)啟動(dòng)無關(guān)。
/usr/lib不同于/lib,這里的庫不是公共庫
/usr/local用來安裝第三方軟件
/usr/local/(s)bin
/usr/local/(s)bin
root@hao:~# ls / usr bin games include lib local sbin share src
二、Linux文件目錄命名規(guī)則 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
1、長度不能超過255個(gè)字符
2、嚴(yán)格區(qū)分大小寫
3、不能使用/
三、目錄管理 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
前面講的ls cd pwd命令外,還有下面命令
1、mkdir(make directory):創(chuàng)建空目錄
-p:未加該選項(xiàng)時(shí),創(chuàng)建目錄一定要保證其父目錄的存在,如下面的mkdir x/y/z要?jiǎng)?chuàng)建z目錄,一定要保證x與y存在,如果不存在則需要先創(chuàng)建x再創(chuàng)建y然后再創(chuàng)建z。加上該選項(xiàng)可以在沒有父目錄的情況下,連同父目錄一塊創(chuàng)建。
-v(verbose):顯示創(chuàng)建過程可以和-p選項(xiàng)一起使用
root@hao:~# mkdir x root@hao: ~# ls x root@hao: ~# mkdir x/ y root@hao: ~# mkdir x/y/ z root@hao: ~# sudo apt-get install tree Reading package lists... Done Building dependency tree Reading state information... Done ... root@hao: ~ # tree x x ` -- y ` -- z 2 directories, 0 files
root@hao:~# mkdir -p m/n/ t root@hao: ~ # tree m m ` -- n ` -- t 2 directories, 0 files
?
? 使用-pv,及花括號(hào)展開,來一次創(chuàng)建多個(gè)目錄
root@hao:~# mkdir -pv /mnt/test/{x/ m,y} mkdir : created directory `/mnt/test ' mkdir : created directory `/mnt/test/x ' mkdir : created directory `/mnt/test/x/m ' mkdir : created directory `/mnt/test/y ' root@hao:~# tree / mnt / mnt ` -- test |-- x | `-- m ` -- y 4 directories, 0 files
使用-pv,在/mnt/test下創(chuàng)建 a_b,a_c,d_b,d_c
root@hao: ~# mkdir -pv /mnt/test/ {a,d}_{b,c} mkdir : created directory `/mnt/test/a_b ' mkdir : created directory `/mnt/test/a_c ' mkdir : created directory `/mnt/test/d_b ' mkdir : created directory `/mnt/test/d_c ' root@hao:~# tree / mnt / mnt ` -- test |-- a_b |-- a_c |-- d_b |-- d_c |-- x | `-- m ` -- y 8 directories, 0 files
2、rmdir(remove directory)刪除目錄
只能刪除空目錄,如果該目錄刪除,其父目錄也為空,則其父目錄也刪除,如此遞歸
root@hao:~# rmdir /mnt/test/ y root@hao: ~# tree / mnt / mnt ` -- test |-- a_b |-- a_c |-- d_b |-- d_c ` -- x ` -- m 7 directories, 0 files
root@hao:~# tree / root / root |-- m | `-- n | `-- t ` -- x ` -- y ` -- z 6 directories, 0 files
root@hao:~# rmdir -p /root/x/y/ z rmdir : failed to remove directory `/root ' : Directory not empty root@hao:~# tree / root / root ` -- m ` -- n ` -- t 3 directories, 0 files
?
?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
