Unix Shell - Difference between sudo -u and su -c ?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2007 > Difference between sudo -u and su -c ?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Difference between sudo -u and su -c ?
Adam Funk

2007-02-23, 1:18 pm

Are there any differences in the effects of the following two
commands?

# sudo -u foo /sbin/bar --option

# su -c '/sbin/bar --option' foo


Thanks,
Adam
Stephane CHAZELAS

2007-02-23, 1:18 pm

2007-02-23, 19:09(+00), Adam Funk:
> Are there any differences in the effects of the following two
> commands?
>
> # sudo -u foo /sbin/bar --option
>
> # su -c '/sbin/bar --option' foo

[...]

Yes, the su interface is not standardized and varies from system
to system.

sudo will affect the environment in a different way as su. wrt
to additional groupids, you may get different behaviors.

su will use the user's shell (it may not be a Bourne-like
shell!) to execute the command on most systems, while sudo won't
use a shell. The behavior of sudo is tunable by a configuration
file. For su, it depends on the system.

sudo is not as commonly found as su.

There's only one implementation of su (though there are
different versions), so it's more consistent from system to
system.

--
Stéphane
Stephane CHAZELAS

2007-02-23, 7:17 pm

2007-02-23, 19:15(+00), Stephane CHAZELAS:
[...]
> There's only one implementation of su (though there are

of sudo

sorry,

> different versions), so it's more consistent from system to
> system.



--
Stéphane
Adam Funk

2007-02-23, 7:17 pm

On 2007-02-23, Stephane CHAZELAS wrote:

....[vbcol=seagreen]
> su will use the user's shell (it may not be a Bourne-like


Do you mean the shell of the user who is running su, or the shell of
user foo (in the example above)?

> shell!) to execute the command on most systems, while sudo won't
> use a shell. The behavior of sudo is tunable by a configuration
> file. For su, it depends on the system.
>
> sudo is not as commonly found as su.
>
> There's only one implementation of sudo (though there are

[following your subsequent correction]
> different versions), so it's more consistent from system to
> system.


So it's more consistent to use sudo *if* it's available on my system.
(Personally, I've never tried to use either on a system which didn't
have sudo.)
Michael Paoli

2007-02-25, 1:25 am

On Feb 23, 1:52 pm, Adam Funk <a24...@yahoo.com> wrote:
> On 2007-02-23, Stephane CHAZELAS wrote:
> Do you mean the shell of the user who is running su, or the shell of
> user foo (in the example above)?


foo - su(1) will use the login shell of the target login

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com