日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux文件查找命令具体解释-which whereis find locate

發(fā)布時間:2024/4/15 linux 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux文件查找命令具体解释-which whereis find locate 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原創(chuàng)BLog。轉(zhuǎn)載請注明出處

http://blog.csdn.net/hello_hwc?

viewmode=contents

which命令

首先查看man which的說明
which - shows the full path of (shell) commands.
在$PATH文件夾下查找命令的絕對路徑,PATH配置不同,查找的結(jié)果也不同
查看系統(tǒng)的PATH
[root@localhost testForCsdn]# echo $PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin使用舉例
[root@localhost testForCsdn]# which ls alias ls='ls --color=tty'/bin/ls過濾掉alias中的信息
[root@localhost testForCsdn]# which --skip-alias ls /bin/ls
whereis命令
man whereiswhereis - locate the binary, source, and manual page filesfor a command從db中查找系統(tǒng)特定二進(jìn)制文件。源文件。和manual page文件
說明:db是系統(tǒng)文件信息的快照。保存在本地數(shù)據(jù)庫里,查找速度會非常快、db每隔一段時間更新。假設(shè)要手動更新,使用命令
updatedb選項
-b : 僅僅找二進(jìn)制文件?
-m: 僅僅找在說明文件manual路徑下的文件?
-s : 僅僅找source源文件?
-u : 沒有說明文檔的文件
舉例
1、列出與init相關(guān)的文件
[root@localhost testForCsdn]# whereis init init: /sbin/init /etc/init.d /usr/share/man/man8/init.8.gz
2、僅僅查找二進(jìn)制文件
[root@localhost testForCsdn]# whereis -b init init: /sbin/init /etc/init.d
locate
從db中,這里的db和whereis中的db一樣。找出系統(tǒng)中與指定名稱全部的相關(guān)文件
經(jīng)常使用選項
-b 只匹配base name
-c 統(tǒng)計數(shù)目
-r 正則匹配
-w 匹配完整的路徑名稱
-d 指定DBPATH,不用默認(rèn)的/var/lib/mlocate/mlocate.db
舉例
[root@localhost ~]# locate -c init 601 [root@localhost ~]# locate -bc init 486<pre name="code" class="plain">[root@localhost ~]# locate init | mroe
find
從磁盤上查找文件,查找時能夠指定路
1、-name通過名稱查找
[root@localhost ~]# find /etc -name init /etc/sysconfig/init
2、-size通過大小查找
[root@localhost ~]# find testForCsdn/ -size -2048 testForCsdn/ testForCsdn/file.txt testForCsdn/file.softlink testForCsdn/file.hardlink
3、 -user通過全部者查找
[root@localhost ~]# find testForCsdn/ -user root testForCsdn/ testForCsdn/file.txt testForCsdn/file.softlink testForCsdn/file.hardlink
4、-ctime/mtime/atime -cmin/mmin/amin
c change 如權(quán)限改變
a access 訪問
m modify 改動
time依照天為單位

min依照分鐘為單位

查找一小時內(nèi)訪問過的文件

[root@localhost ~]# find testForCsdn/ -amin -60 testForCsdn/ testForCsdn/file.txt testForCsdn/file.softlink testForCsdn/file.hardlink
5、-type 依照類型來查找
經(jīng)常使用類型
f 二進(jìn)制
l 軟連接
d 文件夾
[root@localhost ~]# find testForCsdn/ -type l testForCsdn/file.softlink
6、-inum
查找指定inode的文件

查找指定inode然后產(chǎn)出

查找指定inode然后刪除該文件

find / -inum 15 –exec rm –rf {} \;


7、-a -r

a and
r or
多個條件同一時候查找
查找大小小于2M而且類型是軟連接的文件
[root@localhost ~]# find testForCsdn/ -size -2048 -a -type l testForCsdn/file.softlink

8、exec對查找的結(jié)果進(jìn)行處理
查找大小小于2M而且類型是軟連接的文件,然后顯示具體信息
[root@localhost ~]# find testForCsdn/ -size -2048 -a -type l -exec ls -l {} \; lrwxrwxrwx 1 root root 8 Oct 24 20:32 testForCsdn/file.softlink -> file.txt解釋下:這里的{}是查找的結(jié)果,分號。代表結(jié)果。用\進(jìn)行轉(zhuǎn)義


Grep

附上之前寫的一篇鏈接

Grep的9個經(jīng)典使用場景

http://blog.csdn.net/hello_hwc/article/details/40017833







轉(zhuǎn)載于:https://www.cnblogs.com/yfceshi/p/7063367.html

總結(jié)

以上是生活随笔為你收集整理的Linux文件查找命令具体解释-which whereis find locate的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。