我正在使用drupal和aegir。 Aegir自动执行站点创建的许多任务。 Aegir具有控制Apache，我以root身份登录，我想重新启动Apache服务器，但我想代表Aegirs执行它。不幸的是，我不知道Aegir密码，所以基本上我想知道如何像其他用户那样sudo。
I'm using drupal and Aegir. Aegir automates many tasks of site creation. Aegir has control of Apache, I'm logen in as root, and I want to restart the Apache server, but I want to do it on Aegirs behalf. Unfortunately I do not know the Aegir password, so basically I'm wondering how to sudo something as another user.
sudo -u <username> <command>
sudo accepts a user parameter, which will run it as that user.
Alternatively, since you are root:
su <username> -c <command>
su aegir is what you're looking for, assuming the username is
man su will give you more info on the
That user likely won't be able to actually restart Apache if it's running on port 80, unless specifically configured to be allowed to do so. By default,
root is the only user that can bind a service to a low port number.
You should be able to do the following
runuser -l <username> -c <command>
runuser -l Aegir -c service httpd restart
But if you are root you can just su to the user with out a password.
su -l Ageir
You can run as user using -u. This will not open programs as you are "logged in" as that user, so you will have to specify the whole path.
Becomes this, if the normal user is Ubuntu:
sudo -u ubuntu /home/ubuntu/.local/bin/jupyter notebook
Find the location of Jupyter:
which jupyter #Result: /home/ubuntu/.local/bin/jupyter