查看命令所在路径-which-常用

    技术2025-05-21  88

    1、which :查命令所在路径,常用

    [root@CCTV ~]#which cp alias cp='cp -i' /usr/bin/cp [root@CCTV ~]#which ls alias ls='ls --color=auto' /usr/bin/ls [root@CCTV ~]#which ip /usr/sbin/ip [root@CCTV ~]#

    2、whereis 显示命令、源码及说明文档等的路径

    [root@CCTV ~]#whereis ls ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz //路径+帮助 [root@CCTV ~]#whereis -b ls //-b 只查找二进制命令,相当于which ls: /usr/bin/ls [root@CCTV ~]# [root@CCTV ~]#man whereis whereis - locate the binary, source, and manual page files for a command

    3、locate:快速定位文件路径

    查找文件路径,是从数据库里(/var/1ib/mlocate/mlocate.db)查询 用updatedb命令更新数据库 C7默认不安装

    yum install mlocate -y //安装,跳过确认

    Processed: 0.017, SQL: 12