Something about su and sudo
su - run a shell with substitute user and group IDs ( http://linux.die.net/man/1/su )
sudo, sudoedit - execute a command as another user ( http://linux.die.net/man/8/sudo )
The sudo allows a permitted user to execute a command as a superuser or another user as specified in the sudoers file ( which we can edit by visudo command ). The su is frequently use with -c ( --command ). But we put those 2 together like below example
$ sudo su -c "whoami;echo $HOME" # may be you'll get root and current user's home
$ sudo -u hudson sh -c "whoami;pwd;whoami"
ref http://linux.die.net
sudo, sudoedit - execute a command as another user ( http://linux.die.net/man/8/sudo )
The sudo allows a permitted user to execute a command as a superuser or another user as specified in the sudoers file ( which we can edit by visudo command ). The su is frequently use with -c ( --command ). But we put those 2 together like below example
$ sudo su -c "whoami;echo $HOME" # may be you'll get root and current user's home
$ sudo -u hudson sh -c "whoami;pwd;whoami"
ref http://linux.die.net
Comments
Post a Comment