which 可以查找可执行文件的位置
|
1
2 |
evilxr@IdeaPad:~$ which ping/bin/ping |
whereis
whereis -m 可查询到命令的帮助文档在什么地方
|
1
2
3
4 |
evilxr@IdeaPad:~$ whereis -m lsls: /usr/share/man/man1/ls.1.gzevilxr@IdeaPad:~$ whereis -m pwdpwd: /usr/share/man/man1/pwd.1.gz |
|
1
2 |
evilxr@IdeaPad:~$ whereis pwdpwd: /bin/pwd /usr/include/pwd.h /usr/share/man/man1/pwd.1.gz |
输出信息有三条
1.命令本身所在目录
2.其源文件所在目录
3.其帮助文档所在目录
locate 基于本地计算机数据库(计算机磁盘信息),速度比find快些。locate一般是在晚上更新数据库,但是也可以自己手动更新
|
1 |
root@IdeaPad:~# sudo updatedb |
|
1
2
3
4
5
6
7
8 |
root@IdeaPad:~/test# ls1.txt 2.txt aa.tar.gz ab.tar.bz2 ac.tar ac.tar.bz2 ac.tar.gzroot@IdeaPad:~/test# locate aa.tar.gz /root/test/aa.tar.gzroot@IdeaPad:~/test# cd /tmproot@IdeaPad:/tmp# locate aa.tar.gz /root/test/aa.tar.gzroot@IdeaPad:/tmp# |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
创建一个新文件,用locate试试~root@IdeaPad:~/test# touch aobamaroot@IdeaPad:~/test# ed aobama0a我是新创建的文件,看下locate命令能找到我么~.w63qroot@IdeaPad:~/test# locate aobamaroot@IdeaPad:~/test# 结果找不到~ |
|
1
2
3
4
5 |
更新数据库后看下:@IdeaPad:~/test# sudo updatedbroot@IdeaPad:~/test# locate aobama/root/test/aobamaroot@IdeaPad:~/test# |
find 命令 全盘扫描,类似windows的查找;速度比较慢
find可以基于文件名查找
|
1
2
3
4
5
6 |
root@IdeaPad:~# find ./ -name ‘te*‘./testroot@IdeaPad:~# find ./ -name ‘1*‘./test/1.txt./1.txtroot@IdeaPad:~# |
原文地址:http://www.cnblogs.com/evilxr/p/3758444.html