su command question

Smoot Carl-Mitchell smoot at tic.com
Sat Jul 5 17:54:32 UTC 2008


On Sat, 2008-07-05 at 18:01 +0100, Alan Milnes wrote:
> Smoot Carl-Mitchell wrote:
> > On Sat, 2008-07-05 at 13:51 +0100, Alan Milnes wrote:
> > 
> >> In the end both ways work, both ways run it with root privileges, I 
> >> think my way is cleaner but this is Linux there's always more than one 
> >> option.
> > 
> > No, my example runs it with the privileges of the user "ventrilo" which
> > is quite different than running the command with root privileges.
> 
> Are you sure - the su is telling it to run with root privileges isn't 
> it? Maybe it's my RHEL background where scripts to start services etc 
> are normally programmatically run as root rather than as a user invoking 
> su privileges.

"su" lets you run a command with the privileges of another user. The
default user is "root", but if you specify the user on the command line
then it runs with the privileges of the user specified. e.g.

su -c echo hello

Run "echo hello" with "root" privileges

su foo -c echo hello

Run "echo hello" with the privileges of the user "foo".

Unless the invoker of "su" is "root", it will ask for the credentials
(e.g. password) of the user.
-- 
Smoot Carl-Mitchell
System/Network Architect
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list