locate命令是在後臺數據庫中按文件名查找,查找速度快,非實時的。shell
yum -y install mlocate數據庫
updatedbcentos
locate ifcfg-eth0
ide
whereis查找命令路徑和幫助文件
blog
whereis -b cmd // 返回命令路徑
ip
whereis -m cmd // 返回幫助文件路徑
cmd
which cmd 返回命令路徑
it
find 路徑 選項 表達式 動做class
根據文件大小查找
// 查找/etc目錄下文件大小大於5M的文件
find /etc/ -size +5M
後臺
根據文件類型查找
//查找/dev目錄下塊設備文件
find /dev -type b
根據時間查找
//查找用戶家目錄下7天前的文件
根據用戶查找
// 查找centos家目錄下文件
find /home/centos -user centos根據權限查找
// 查找755權限文件
find ./shell_scripts/ -perm 755 -ls
-print :打印查找到的內容(默認)
-ls:以長格式顯示的方式打印查找到的內容
-delete:刪除查找到的文件(僅能刪除空目錄)
-ok:後面跟自定義Shell命令(會提示是否操做)
-exec:後面跟自定義Shell命令(標準寫法 -exec \;)