linux day9 文件查找命令

有时我们再用yum安装一个命令的时候会找不到
就要用 yum provides 命令名 查下命令属于那个包

locate //查找文件或者目录
示例:locate /etc/sh       //搜索含有/etc/sh的目录或文件
[root@db04 ~]# locate /etc/sh
/etc/shadow
/etc/shadow-
/etc/shells
/usr/local/etc/shadow
/usr/local/etc/shadow-
/usr/local/etc/shells

示例:locate -i /etc/sh    //忽略大小写

which   //查找系统PATH变量目录下的命令(绝对路径)
[root@db04 ~]# which ls
alias ls='ls --color=auto'
    /bin/ls

[root@db04 ~]# type -a ls
ls is aliased to `ls --color=auto'
ls is /bin/ls

[root@db04 ~]# which useradd
/usr/sbin/useradd

whereis //查找文件索引数据库下的命令、源文件、man文件。非PATH变量查找,所以查找的面比which要广 -b,-m
[root@db04 man1]# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1 /usr/share/man/man1p/ls.1p.gz
[root@db04 man1]# whereis -b ls
ls: /bin/ls
posted @ 2020-04-21 12:55  nick_xm  阅读(106)  评论(0编辑  收藏  举报