linux 查找文件的命令

1、which

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

2、whereis

[[email protected] ~]# 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

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

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

例子:

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

4、find

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

linux 查找文件的命令的相关文章

linux查找文件夹命令

查找命令: 查找根目录下查找文件夹名称叫www.91cnm.com的目录地址 find / -name www.91cnm.com -d 1 查找/var/www/目录下叫index.php的文件 find /var/www/ -name index.php 1 查找根目录下所有已".sh"结尾的文件 find / -name *.sh 1 下载命令:下载 www.91cnm.com/index.php的资源 wget www.91cnm.com/index.php (&下载大

linux查找文件的命令【转】

原文链接:http://www.ruanyifeng.com/blog/2009/10/5_ways_to_search_for_files_using_the_terminal.html 1. find find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件. find的使用格式如下: $ find <指定目录> <指定条件> <指定动作> - <指定目录>: 所要搜索的目录及其所有子目录.默认为当前目录. - <指定条件>: 所要

Linux查找文件

which 可以查找可执行文件的位置 ? 1 2 [email protected]:~$ which ping /bin/ping whereis whereis -m 可查询到命令的帮助文档在什么地方 ? 1 2 3 4 [email protected]:~$ whereis -m ls ls: /usr/share/man/man1/ls.1.gz [email protected]:~$ whereis -m pwd pwd: /usr/share/man/man1/pwd.1.gz

linux查找文件总结

locate:非实时的查找,查找过程根据全系统文件数据库进行的,查找方式非精确. 默认系统定时写入数据库. 优点:查找速度快. 若无数据库,可以手动创建,updatedb,但是该命令处理时间会很长. find:实时的,精确的,遍历指定目录的所有文件完成查找,查找速度慢. 支持众多查找标准(支持正则表达式) find 查找路径   查找标准   查找到以后处理操作 默认当前路径默认当前路径下所有文件默认为显示区分大小写 匹配标准: -name 'fliename' 例子:find /tmp -na

CentOS定位、查找文件的命令

定位.查找文件的命令 命令 功能 命令 功能 which 从path中找出文件的位置 find 找出所有符合要求的文件 whereis 找出特定程序的路径 locate 从索引中找出文件位置 9.1 which 语法 which command 说明 依序从path环境变量所列的目录中找出command的位置,并显示完整路径的名称.在找到第一个符合条件的程序文件时,就立刻停止搜索,省略其余未搜索目录. 范例,找出ls命令的程序文件的位置: which ls 系统输出: /usr/bin/ls 9

[转] Linux 查找文件内容

Linux查找文件内容的常用命令方法. 从文件内容查找匹配指定字符串的行: $ grep "被查找的字符串" 文件名例子:在当前目录里第一级文件夹中寻找包含指定字符串的.in文件grep "thermcontact" */*.in 从文件内容查找与正则表达式匹配的行:$ grep –e "正则表达式" 文件名 查找时不区分大小写:$ grep –i "被查找的字符串" 文件名 查找匹配的行数:$ grep -c "被

linux 压缩文件的命令总结

Linux压缩文件的读取 ·    *.Z       compress 程序压缩的档案: ·    *.bz2     bzip2 程序压缩的档案: ·    *.gz      gzip 程序压缩的档案: ·    *.tar     tar 程序打包的数据,并没有压缩过: ·    *.tar.gz  tar 程序打包的档案,其中并且经过 gzip 的压缩! ·    *.zip     zip 程序压缩文件 ·    *.rar     rar 程序压缩文件 Compress压缩文件 [

Linux删除文件夹命令实例

linux删除文件夹命令 在用Linux的时分,有时分要删除一个文件夹,常常会提示次此文件非空,没法删除,这个时分,必需运用rm -rf命令.关于一些小白用户常常在运用Linux命令,会十分当心,以免搞出一些事情,下面小编将教细致教大家如何运用linux命令删除文件夹,需求的请珍藏. linux删除文件夹命令实例: rm -rf /var/log/httpd/access 将会删除/var/log/httpd/access目录以及其下所有文件.文件夹 linux删除文件命令实例: rm -f /

linux查找文件命令总结

使用电脑的时候,经常需要查找文件在Linux中,有很多方法可以做到这一点.国外网站LinuxHaxor总结了五条命令,你可以看看自己知道几条.大多数程序员,可能经常使用其中的2到3条,对这5条命令都很熟悉的人应该是不多的.1. findfind是最常见和最强大的查找命令,你可以用它找到任何你想找的文件.find的使用格式如下:$ find <指定目录> <指定条件> <指定动作>- <指定目录>: 所要搜索的目录及其所有子目录.默认为当前目录.- <指