PDA

View Full Version : Linux/Bash: Run a command as another user



sunil.thaha
5th December 2006, 08:04
Other than the sudo is there a way to execute a command as another user ?
Suppose there a cluster manager running as ROOT and It accepts commands from users . All the commands have to be run using the submitted users privilege. So it there a better solution other than using the sudo command ?

Just got the su username -c "command " .
Any other ways ?

wysota
5th December 2006, 10:49
You can use the setuid bit to run a particular command as the owner of the executable:



# chown someuser command
# chmod u+s command
$ ./command
"command" will get run with "someuser" priviledges.