which systemctl
时间: 2023-12-31 22:06:13 浏览: 20
`which`命令用于查找指定命令的可执行文件路径。在Linux系统中,`systemctl`是一个用于管理系统服务的命令。它可以用来启动、停止、重启、开机自启等操作。下面是使用`which`命令查找`systemctl`可执行文件路径的示例:
```shell
which systemctl
```
输出结果将会是`systemctl`命令的可执行文件路径。
相关问题
解析一下另外这条linux命令[ "$(which systemctl 2>/dev/null)"x != ""x ] && systemctl list-unit-files --type service --type socket|egrep '^\bdiscard\b|^\bsendmail\b|^\bident\b|^\bprinter\b|^\bbootps\b|^\blpd\b|^\bnfs\b|^\bnfs.lock\b|^\bypbind\b|^\bdaytime\b|^\btime\b|^\becho\b|^\bchargen\b|^\bntalk\b|^\btftp\b|^\bamanda\b|^\bcups\b|^\bcups-lpd\b|^\beklogin\b|^\bekrb5-telnet\b|^\bfinger\b|^\bgssftp\b|^\bimap\b|^\bimaps\b|^ \bipop2\b|^\bipop3\b|^\bklogin\b|^\bkrb5-telnet\b|^\bkshell\b|^\bktalk\b|^\brexec\b|^\brlogin\b|^\brsh\b|^\brsync\b|^\btalk\b|^\btcpmux-server\b|^\btelnet\b|^\buucp\b'|awk 'BEGIN{num=0} /enabled/{num+=1;print $0}END{if(num>0){print "result=false"}else{print "result=true"}}'
这条 Linux 命令的作用是检查系统中是否安装了 systemctl 命令。具体来说,它会先执行 which systemctl 命令,将结果输出到 /dev/null 中,然后再将标准错误输出重定向到 /dev/null 中。最后,它会将 which systemctl 命令的输出与空字符串进行比较,如果不相等,则表示系统中已经安装了 systemctl 命令。这条命令通常用于 shell 脚本中,以检查系统是否支持 systemd 系统管理器。
怎么找到systemctl的目录
systemctl 命令本身并没有所在的目录,它是 systemd 的一部分,通常会被安装在系统的 PATH 环境变量中。
如果您想查找 systemctl 命令的具体路径,可以使用以下命令:
```
which systemctl
```
该命令会输出 systemctl 命令的完整路径。在大多数 Linux 发行版中,systemctl 命令的路径通常为 `/bin/systemctl` 或者 `/usr/bin/systemctl`。
您也可以使用以下命令来搜索 systemctl 命令所在的位置:
```
whereis systemctl
```
该命令会输出 systemctl 命令所在的路径,以及其它相关文件的路径。在大多数 Linux 发行版中,systemctl 命令的路径通常为 `/bin/systemctl` 或者 `/usr/bin/systemctl`。