Can I sudo a command on behalf of 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 aegir
. man su
will give you more info on the su
command.
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>
e.g
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
J