4、文件的軟硬鏈接
分區(qū)的每個block默認(rèn)大小是4K,一個block只能存儲一個文件;inode相當(dāng)于分區(qū)的索引,記錄了文件的屬性信息;
硬鏈接,文件的inode相同,實質(zhì)上指的是相同的文件,相當(dāng)于一個文件兩個名稱,修改其中的一個文件,另一個也會改變,刪除其中一個文件,不會影響另一個文件:
1234 [root@linuxidc tmp]# touch aa
[root@linuxidc tmp]# ln aa bb
[root@linuxidc tmp]# ls -i aa bb
102819918 aa 102819918 bb
inode只能記錄本分區(qū)的block信息,硬鏈接不能跨分區(qū)
創(chuàng)建一個文件夾,默認(rèn)就會有2個硬鏈接,一個是文件夾本身,另一個是文件夾的".":, “..” 返回上一層目錄也是一個硬鏈接:
”[root@linuxidc tmp]# mkdir aa
[root@linuxidc tmp]# ls -ld aa/
drwxr-xr-x. 2 root root 6 Jan 14 16:32 aa/
5、文件查找
whereis + 文件
which + 命令
locate:利用數(shù)據(jù)庫來根據(jù)名字查詢文件,查詢速度很快,但是數(shù)據(jù)庫一周更新一次;可以使用updatedb命令手工更新數(shù)據(jù)庫:
find: find + 目錄+屬性+值
屬性值:
1、name;
2、size;
3、user group;
4、uid,gid;
5、perm;查找權(quán)限 222完全匹配,-222至ugo分別少要含有相對應(yīng)的權(quán)限222,+222,/222或關(guān)系,ugo分別只要滿足其中一個權(quán)限即可
6、type;
7、ctime/cminu;
8、newer;
find查找出來的內(nèi)容要執(zhí)行命令,則按照以下兩種方式操作:
[root@linuxidc tmp]# find -name "*" | xargs ls -l
[root@linuxidc tmp]# find -ctime +1 -exec ls -l {} \;
6、find命令參數(shù)詳解
SYNOPSIS語法格式
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
選項:
-P:不查找鏈接文件內(nèi)容,這是默認(rèn)選項;
-L:查找鏈接文件內(nèi)容,如果文件時鏈接文件,那么加入這個選項,命令將會查看鏈接所指的文件的內(nèi)容:
例如,2個鏈接文件,一個指向文件,一個指向目錄:
[root@linuxidc tmp]# ll bb cc
lrwxrwxrwx. 1 root root 12 Jan 15 14:59 bb -> /root/passwd
lrwxrwxrwx. 1 root root 5 Jan 15 15:11 cc -> /root
不加-L選項時,查找bb和cc文件:
[root@linuxidc tmp]# find bb cc -type f 沒有結(jié)果
加入-L選項,將會查找鏈接文件指向的真正內(nèi)容:
[root@linuxidc tmp]# find -L bb cc -type f
-H:這個選項和-L選項類似,不同的區(qū)別是,假如查找的鏈接文件是壞鏈接,則將會顯示鏈接文件的信息;
-follow:這個選項后面的鏈接文件也會被指向其鏈接的真正文件;
-D: 診斷信息
診斷選項:
help Explain the debugging options
tree Show the expression tree in its original and optimised form.
stat Print messages as files are examined with the stat and lstat system calls. The find program tries to min?imise such calls.
opt Prints diagnostic information relating to the optimisation of the expression tree; see the -O option.
rates Prints a summary indicating how often each predicate succeeded or failed.
-Olevel;優(yōu)化層級
0:
1:默認(rèn)層級
2:
3:
表達(dá)式expression由三個部分組成,由運算符分隔開:
選項option,所有選項返回true值:
常用選項
-d,-depth:處理目錄的內(nèi)容的層級
-maxdepth:處理目錄的最大層級;
-noleaf:針對于CD-ROM,MS-DOS,AFS等不符合unix文件系統(tǒng)規(guī)范的文件;
測試tests:
-ctime;
-atime:
-perm:
-iname:
-path
-mmin:
-mtime:
-newer:
-name
-size:文件大小
-type:文件類型:b,c,d,f,l,p,s,d
-uid:
-gid:
2015職稱計算機(jī)考試書PowerPoint2007中 .. 定價:¥45 優(yōu)惠價:¥42 更多書籍 | |
2015年全國職稱計算機(jī)考試教材(2007模 .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |