Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-04-2006, 04:52 AM   #1
LQ Newbie
Registered: Dec 2006
Posts: 16

Rep: Reputation: 0
Su Vs Sudo????


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

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?
Old 12-04-2006, 05:05 AM   #2
Senior Member
Registered: May 2001
Location: Indiana
Distribution: Gentoo, Debian, RHEL, Slack
Posts: 1,555

Rep: Reputation: 46
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.

Last edited by musicman_ace; 12-04-2006 at 05:07 AM.
Old 12-04-2006, 05:10 AM   #3
LQ Newbie
Registered: Dec 2006
Posts: 16

Original Poster
Rep: Reputation: 0
Ausome thanx heaps dude, that clarified alot =D
Old 12-04-2006, 05:55 AM   #4
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 75
Another thing to note. In most configurations, sudo asks you for your own password but su needs the root password.
Old 12-04-2006, 05:57 AM   #5
Senior Member
Registered: Dec 2003
Posts: 3,161
Blog Entries: 4

Rep: Reputation: 136Reputation: 136
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.
Old 12-04-2006, 05:58 AM   #6
Senior Member
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 47
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. . .
Old 12-04-2006, 10:07 AM   #7
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
if your using su you should use the c flag.
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.
Old 12-04-2006, 11:28 AM   #8
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
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.

Old 12-04-2006, 05:41 PM   #9
LQ Newbie
Registered: Dec 2006
Posts: 16

Original Poster
Rep: Reputation: 0
Excellent thanx heaps guys =D
Old 12-04-2006, 05:48 PM   #10
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.3
Posts: 17,548

Rep: Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423Reputation: 2423
Also, su actually means switch user (not super user), so as root, you can then switch to any other user.
Note that
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 03:20 PM
Sudo without having to type "sudo?" Mitch G Linux - Security 3 09-28-2006 02:16 PM
sudo XaViaR Linux - General 6 06-21-2005 06:12 PM
About sudo alnreddy Linux - Security 3 06-13-2005 12:53 PM
sudo pk21 Linux - Newbie 7 10-07-2003 07:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration