linux文件名查找which,whereis,locate

发布时间:2022-11-22 20:24:04阅读:77次
1.文件名查找使用find查询时,由于磁盘查询,所以速度较慢,所以linux下查询更常使用which,whereis,locate来查询,由于是利用数据库查询,所以速度很快。2.which我们常用的ls命令,如果我们想知道这些常用命令放在哪儿,就使用which命令来查询地址。which使用PATH环境变量去查找文件名,which-a返回所有的查到的命令,默认返回第一条。$whichgrep/bin/grep$whichllaliasll='ls-l--color=tty'/bin/ls#使用alias别名3.whereiswhereis用来查询程序名$whereiswhereis[-sbmu][-SBMdir...-f]name...-b:查找二进制格式文件-s:查找source源文件-m:查找在说明文件manual路径下的文件-u:查找不在上述三个选项中的特殊文件例如$whereisgrepgrep:/bin/grep/usr/man/man1/grep.1.gz/usr/man/man1p/grep.1p.gz#查询二进制文件$whereis-bgrepgrep:/bin/grep#查询手册说明文件mangrep$whereis-mgrepgrep:/usr/man/man1/grep.1.gz/usr/man/man1p/grep.1p.gz3.locatelinux将系统内文件列在一个数据库文件(arb/slocate/slocate.db)。locate通过数据库文件查询。一般这个文件每天更新一次,配置在/etc/updatedb.conf里面配置是否每天更新,以及更新目录。可以手动运行$updatedb来更新数据库。使用locate,后面跟命令即可$locatepasswd

本文来自系统大全为您提供如需转载请注明!推荐win10下载

排行榜