天天看點

Centos7常用指令[檔案搜尋]

Centos7常用指令[檔案搜尋]

------------------------------------------------------------------------------

# 從/開始進入根檔案系統搜尋檔案和目錄

[root@localhost ~]# find / -name file1

# 搜尋屬于使用者user1的檔案和目錄

[root@localhost ~]# find / -user user1

# 在目錄/home/user1中搜尋帶有.bin結尾的檔案

[root@localhost ~]# find /home/user1 -name *.bin

# 搜尋在過去100天内未被使用過的執行檔案

[root@localhost ~]# find /usr/bin -type f -atime +100

# 搜尋在10天内被建立或者修改過的檔案

[root@localhost ~]# find /usr/bin -type f -mtime -10

# 搜尋以.rpm結尾的檔案并定義其權限

[root@localhost ~]# find / -name *.rpm -exec chmod 755 ‘{}’ \;

# 搜尋以.rpm結尾的檔案,忽略光驅、捷盤等可移動裝置

[root@localhost ~]# find / -xdev -name *.rpm

# 尋找以.ps結尾的檔案-先運作updatedb指令

[root@localhost ~]# locate *.ps

# 顯示一個二進制檔案、源碼或man的位置

[root@localhost ~]# whereis halt

# 顯示一個二進制檔案或可執行檔案的完整路徑

[root@localhost ~]# which halt

繼續閱讀