我可以通过systemctl命令找到哪个用户正在运行服务吗?

Rub*_*una 10 systemd

我想弄清楚哪个用户正在使用给定的服务。systemctl status似乎没有提供该信息

\n\n
sudo systemctl status nginx.service\nsudo systemctl status emperor.uwsgi.service\n\xe2\x97\x8f emperor.uwsgi.service - uWSGI Emperor\n   Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: disabled)\n   Active: failed (Result: start-limit) since Tue 2020-03-31 11:26:34 UTC; 7min ago\n  Process: 31133 ExecStart=/usr/local/bin/pipenv run uwsgi --ini uwsgi.ini (code=exited, status=1/FAILURE)\n Main PID: 31133 (code=exited, status=1/FAILURE)\n\nMar 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\nMar 31 11:26:34 ip-10-28-34-70.eu-west-1.compute.internal systemd[1]: Failed to start uWSGI Emperor.\n
Run Code Online (Sandbox Code Playgroud)\n\n

有什么方法可以从中获取此信息systemctl或者我需要打开单元文件吗?

\n

Ste*_*itt 23

您可以systemctl show为此使用:

systemctl show -pUser,UID nginx
Run Code Online (Sandbox Code Playgroud)

如果User什么也不显示,且UID[not set],则服务正在以 root 身份运行,或者在用户服务的情况下以所有者用户身份运行。