![我可以通过systemctl命令找到哪个用户正在运行服务吗?](https://linux22.com/image/170149/%E6%88%91%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87systemctl%E5%91%BD%E4%BB%A4%E6%89%BE%E5%88%B0%E5%93%AA%E4%B8%AA%E7%94%A8%E6%88%B7%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%E6%9C%8D%E5%8A%A1%E5%90%97%EF%BC%9F.png)
我想弄清楚哪个用户正在使用给定的服务。systemctl status
似乎没有提供该信息
sudo systemctl status nginx.service
sudo systemctl status emperor.uwsgi.service
● emperor.uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Tue 2020-03-31 11:26:34 UTC; 7min ago
Process: 31133 ExecStart=/usr/local/bin/pipenv run uwsgi --ini uwsgi.ini (code=exited, status=1/FAILURE)
Main PID: 31133 (code=exited, status=1/FAILURE)
Mar 31 11:26:34 ip-10-28-34-70.eu-west-1.compute.internal systemd[1]: emperor.uwsgi.service: main process exited, code=exited, status=1/FAILURE
Mar 31 11:26:34 ip-10-28-34-70.eu-west-1.compute.internal systemd[1]: Failed to start uWSGI Emperor.
有什么方法可以从中获取此信息systemctl
或者我需要打开单元文件吗?
答案1
您可以systemctl show
为此使用:
systemctl show -pUser,UID nginx
如果User
什么也不显示,且UID
为[not set]
,则服务正在以 root 身份运行,或者在用户服务的情况下以所有者用户身份运行。