关于linux:每天学一个-Linux-命令51which

26次阅读

共计 628 个字符,预计需要花费 2 分钟才能阅读完成。

昨日举荐: 每天学一个 Linux 命令(50):date

命令简介

which 命令用于查找并显示指定的命令的绝对路径信息,按环境变量 PATH 门路查找。应用 which 命令,也能够看到某个系统命令是否存在。

语法格局

which [options] [--] programname [...]

选项阐明

-a  #打印每个匹配文件名的所有匹配路径名
-V  #打印版本信息

which 退出状态

0 #找到了所有文件名,所有文件都是可执行的
1 #找不到一个或多个文件名,或者文件名不可执行
2 #指定的选项有效

利用举例

显示命令的残缺门路

[root@centos7 ~]# which which
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
 /usr/bin/alias
 /usr/bin/which
[root@centos7 ~]# which ls
alias ls='ls --color=auto'
 /usr/bin/ls
[root@centos7 ~]# which pwd
/usr/bin/pwd
[root@centos7 ~]# which rz
/usr/bin/rz
[root@centos7 ~]# which ifconfig
/usr/sbin/ifconfig

每天学一个 Linux 命令(48):top

每天学一个 Linux 命令(49):free

正文完
 0