搜索文件位置

本文介绍了Linux下常用的文件搜索命令,包括find、locate、whereis及type等,详细解释了每个命令的功能及其用法,并提供了实际操作示例。

搜索命令:
find
locate
whereis
which
type

  1. linux下最强大的搜索命令为”find“。它的格式为:find <指定目录> <指定条件> <指定动作>

    搜索在根目录下名字为datagrip.sh文件的所有位置

    ~$: sudo find / -name 'datagrip.sh'
    /opt/DataGrip-2016.3.4/bin/datagrip.sh
    /usr/local/DataGrip-2016.3.4/bin/datagrip.sh
  2. 使用 locate 搜索linux系统中的文件,它比find命令快。因为它查询的是数据库(/var/lib/locatedb),数据库包含本地所有的文件信息。

    ~$: sudo locate 'datagrip.sh'
    /opt/DataGrip-2016.3.4/bin/datagrip.sh
    /usr/local/DataGrip-2016.3.4/bin/datagrip.sh
  3. 使用 whereis 命令搜索所有可执行文件即二进制文件。使用whereis命令搜索grep二进制文件的命令为

    ~$: whereis grep
    grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
  4. 使用 type 命令查看系统中的某个命令是否为系统自带的命令。

    使用type命令查看cd命令是否为系统自带的命令;

    ~$: type cd
    cd 是 shell 内建

    查看grep 是否为系统自带的命令。

    ~$: type grep
    grep 是 `grep --color=auto' 的别名
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值