歡迎您光臨本站 註冊首頁

Linux文件搜索之find / locate / whereis / which

←手機掃碼閱讀     火星人 @ 2014-03-23 , reply:0

1.find /etc -name my.so

2.locate 是用來通過文件名搜索文件的工具,它的用法也比較簡單。locate 的應用,首先要通過updatedb建立索引資料庫,然後才能應用;如果您新安裝了軟體或者存放了新的文件,也要先運行updatedb命令,以生成最新索引庫。

用法:locate 文件名

我們要先運行updatedb;
[root@localhost ~]# updatedb

舉例: 我們要找vsftpd.conf文件都位於哪個位置;
[root@localhost ~]# locate my.so

3.whereis 是來尋找命令的二進位文件,同時也會找到其幫助文件;

比如我們不知道fdisk工具放在哪裡,我們就可以用whereis fdisk 來查找;

[root@localhost ~]# whereis fdisk
fdisk: /sbin/fdisk /usr/share/man/man8/fdisk.8.gz

如果我們尋找grub在哪裡,應該用如下命令,說明grub位於/sbin目錄,他的幫助文件是grub.8.gz ,也就是man grub;

[root@localhost ~]# whereis grub
grub: /sbin/grub /etc/grub.conf /usr/share/grub /usr/share/man/man8/grub.8.gz

4.which 和where 相似,只是我們所設置的環境變數中設置好的路徑中尋找;比如;
[root@localhost ~]# which fdisk
/sbin/fdisk

[火星人 ] Linux文件搜索之find / locate / whereis / which已經有350次圍觀

http://coctec.com/docs/linux/show-post-115723.html