码迷,mamicode.com
首页 > 系统相关 > 详细

linux 查找文件的命令

时间:2016-08-31 12:22:56      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:linux 查找文件的命令

1、which

[root@lb01 ~]# which passwd
/usr/bin/passwd
# which - shows the full path of (shell) commands. 
# 显示命令的全路径


2、whereis

[root@lb01 ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
# whereis - locate the binary, source, and manual page files for a command
# 为命令:定位二进制文件、源文件、man page文件

3、locate

[root@lb01 ~]# locate passwd
/etc/passwd
/usr/bin/passwd
# locate - find files by name
# 根据名字找出文件名,只要含有关键字的,全部找出来

updatedb# 使用这条命令更新缓存的数据库
/var/lib/mlocate/mlocate.db# 默认缓存的数据库文件
The database searched by default.


例子:

[root@lb01 ~]# touch /etc/chen.txt# 创建新文件
[root@lb01 ~]# locate chen.txt# 找不到,因为还没缓存到/var/lib/mlocate/mlocate.db
[root@lb01 ~]# updatedb # 强制刷新缓存的数据库
[root@lb01 ~]# locate chen.txt# 可以找到了,而且很快,因为读取的是缓存数据库,并没有去读取磁盘
/etc/chen.txt


4、find

[root@lb01 ~]# find / -name chen.txt# find搜索文件系统,实时查找,效率低,因为搜索的是磁盘,但功能最强大
/etc/chen.txt
[root@lb01 ~]# find / -name passwd
/tmp/oldboy/passwd
/etc/passwd
/etc/pam.d/passwd
/usr/bin/passwd
















本文出自 “陈发哥007” 博客,请务必保留此出处http://chenfage.blog.51cto.com/8804946/1844554

linux 查找文件的命令

标签:linux 查找文件的命令

原文地址:http://chenfage.blog.51cto.com/8804946/1844554

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!