忘记文件所在的位置?
咱不怕!
搜索文件的命令为”find“;”locate“;”whereis“;”which“;”type“
find
最强大的搜索命令
格式:
find <指定目录> <指定条件> <指定动作>
例如:在当前目录及子目录下搜索文件名中包含‘html’字段的文件
find ./ -name '*html*'
参考:
locate
locate比find命令快,它查询的是数据库(/var/lib/locatedb),数据库包含本地所有的文件信息。
locate '*mycode*'
whereis
可以搜索linux系统中的所有可执行文件即二进制文件。
$ whereis python
python: /user/bin/python
which
查看系统命令是否存在,并返回系统命令所在的位置。
$ which python
~/.jumbo/bin/python
type
查看系统中的某个命令是否为系统自带的命令。
$ type python
python is home/work/.jumbo/bin/python
$ type ps
ps is /bin/ps
$ type cd
cd is a shell builtin
$ type hahaha
bash: type: hahaha: not found