Linux 如何上搜索文件

使用linux系统难免会忘记文件所在的位置,可以使用以下命令对系统中的文件进行搜索。

搜索文件的命令为”find“;”locate“;”whereis“;”which“;”type“

1、find <指定目录> <指定条件> <指定动作>“

比如使用find命令搜索在根目录下的所有interfaces文件所在位置,

find / -name  "oversea"
root@iZj6cjd6a760ev9yr3yiklZ:~# find / -name  "oversea"
/opt/hpb/oversea
2、使用locate搜索linux系统中的文件,它比find命令快。因为它查询的是数据库(/var/lib/locatedb),数据库包含本地所有的文件信息。使用locate命令在根目录下搜索interfaces文件的
locate oversea
root@iZj6cjd6a760ev9yr3yiklZ:~# locate oversea
/opt/hpb/oversea
/opt/hpb/oversea/oversea-0.0.1-SNAPSHOT.jar
/opt/hpb/oversea/oversea.log
3、使用”whereis“命令可以搜索linux系统中的所有可执行文件即二进制文件。使用whereis命令搜索grep二进制文件的
whereis grep
root@iZj6cjd6a760ev9yr3yiklZ:~# whereis grep
grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
4、 使用type命令查看系统中的某个命令是否为系统自带的命令。
type cd
root@iZj6cjd6a760ev9yr3yiklZ:~# type cd
cd is a shell builtin
root@iZj6cjd6a760ev9yr3yiklZ:~# type grep
grep is aliased to `grep --color=auto'
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值