zoukankan      html  css  js  c++  java
  • linux文件名称查找which,whereis,locate

    1. 文件名称查找


    使用find查询时。因为磁盘查询。所以速度较慢。
    所以linux下查询更常使用which, whereis, locate来查询,因为是利用数据库查询。所以速度非常快。

    2. which


    我们经常使用的ls命令。假设我们想知道这些经常使用命令放在哪儿。 就使用which命令来查询地址。
    which使用PATH 环境变量去查找文件名称,
    which -a 返回全部的查到的命令, 默认返回第一条。

    $ which grep
    /bin/grep
    
    $ which ll
    alias ll='ls -l --color=tty'
            /bin/ls
            #使用alias别名

    3. whereis


    whereis用来查询程序名
    $ whereis
    whereis [ -sbmu ] [ -SBM dir ... -f ] name...
    -b : 查找二进制格式文件
    -s : 查找source 源文件
    -m : 查找在说明文件manual路径下的文件
    -u : 查找不在上述三个选项中的特殊文件
    比如
    $ whereis grep
    grep: /bin/grep /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz
    
    #查询二进制文件
    $ whereis -b grep 
    grep: /bin/grep
    
    #查询手冊说明文件 man grep 
    $ whereis -m grep
    grep: /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz
    

    3. locate


    linux将系统内文件列在一个数据库文件(/var/lib/slocate/slocate.db)。
    locate通过数据库文件查询。
    一般这个文件每天更新一次。 配置在/etc/updatedb.conf
    里面配置是否每天更新。以及更新文件夹。
    能够手动执行
    $ updatedb
    来更新数据库。

    使用locate。后面跟命令就可以


  • 相关阅读:
    部署NetCore项目(本文介绍用用IIS部署)
    vs中添加MySql实体集流程
    一文搞定HashMap的实现原理
    二分查找
    hashcode返回值可能为负数
    哈希碰撞与生日攻击
    并发的第二天
    java并发编程-1
    排序的第一天
    并发的第一天
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/5092362.html
Copyright © 2011-2022 走看看