LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Su Vs Sudo???? (https://www.linuxquestions.org/questions/linux-newbie-8/su-vs-sudo-507317/)

Mash 12-04-2006 04:52 AM

Su Vs Sudo????
 
Hi,

What is the difference between 'su' and 'sudo'??
I thought that these two ways of doing things would be pretty much identical:
(1)
su
<enter password>
yum install someprogram

(2)
sudo yum install someprogram
<enter password>

However, the password that I enter for 'su' works, but it does not work for 'sudo'. Could someone explain?

musicman_ace 12-04-2006 05:05 AM

sudo allows you to run a privelaged program. It does not give you root access to the system. For sudo, you have to be in the /etc/sudoers file & then you can use sudo only for what the administrator gives you permission to execute

su allows you to become root. At that point you can do anything, including run privelaged programs, but you can also do anything else that root could do.

The difference between the two examples you gave is this.
(1) Once you've entered yum install someprogram, you still have root level access to your system. You must type exit to get back to your user level access.

(2) Once you've entered yum install someprogram, you return to your user account access as a normal user.

Mash 12-04-2006 05:10 AM

Ausome thanx heaps dude, that clarified alot =D

reddazz 12-04-2006 05:55 AM

Another thing to note. In most configurations, sudo asks you for your own password but su needs the root password.

vharishankar 12-04-2006 05:57 AM

sudo if configured properly is useful in a multi-user environment - when other users might have to run privileged (root) programs but it's not wise that they have access to the root account. On the other hand, you're likely to use su more often on a home machine with a single user (since you'll be both the administrator and the user and you'll know the root password). In that case, su is probably more convenient.

oneandoneis2 12-04-2006 05:58 AM

Sudo is (mostly) mode secure than su, because you can limit the things it can do: You could, for instance, give every user "sudo" access to the shutdown command if you want to make sure that the PC can be turned off when you're not there. But they wouldn't be able to do anything else.

A badly set-up sudo, tho, is an open invitation for people to become root: "sudo bash" gets the user a root shell, for instance. . .

archShade 12-04-2006 10:07 AM

if your using su you should use the c flag.
e.g.
su -c "yum install someprogram"
<enter password>

This will remove root access after the commad has been executed.
I prefer su to sudo but if i was on a multi user enviroment I can see why sudo would be useful.

Tinkster 12-04-2006 11:28 AM

And, in addition to what Hari said: sudo's greatest advantage over su
is that it leaves an audit-trail; you know who did what at which time.

Ideally in a corporate environment with shared powers (if more than one
person needs to have root-access, and you log to a remote box) it's fairly
safe to say that you'll see who did what, and if someone decided to do a
sudo su - you'd still get a fair idea of as to who might have done bad
things without an actual history entry.


Cheers,
Tink

Mash 12-04-2006 05:41 PM

Excellent thanx heaps guys =D

chrism01 12-04-2006 05:48 PM

Also, su actually means switch user (not super user), so as root, you can then switch to any other user.
Note that
su
and
su -
are different: the 1st makes you root, but with your original non-root env; the 2nd makes you root with root's env.
Similarly for su-ing to other users.


All times are GMT -5. The time now is 04:13 PM.