Linux文件搜索命令

1,locate 文件名
在后台数据库中按文件名搜索,搜搜速度更快
/var/lib/mlocate #locate命令所搜索的后台数据库
updatedb 更新数据库
如果locate命令报错
can not stat () /var/lib/mlocate/mlocate.db': No such file or directory [jing@localhost ~]$ updatedb updatedb: can not open a temporary file for/var/lib/mlocate/mlocate.db’
那么就需要我们手动安装locate
【安装配置】

安装mlocate 
yum install mlocate
生成db数据文件 
[root@root ~]# updatedb 
[root@root ~]# ls /var/lib/mlocate/mlocate.db 
 /var/lib/mlocate/mlocate.db

2,whereis 命令
#搜索命令所在路径以及帮助文档所在位置
whereis ls

[jing@localhost Desktop]$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

3,which 文件名

搜索命令所在文件

[jing@localhost Desktop]$ which ls
alias ls='ls --color=auto'
    /bin/ls

4,PATh环境变量:定义系统搜索命令的路径

jing@localhost Desktop]$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jing/bin

5,find命令:

find [搜索范围] [搜索条件]
#避免大范围搜索,会非常耗费系统资源
#find是在系统当中搜欧所符合条件的文件名。

6,grep命令:

grep [选项] 字符串 文件名
#在文件中匹配符合条件的字符串
欢迎转载,但转载请注明原文链接[博客园: http://www.cnblogs.com/jingLongJun/]
[CSDN博客:http://blog.csdn.net/mergades]。
如相关博文涉及到版权问题,请联系本人。
原文地址:https://www.cnblogs.com/jingLongJun/p/4491036.html