Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the actual benefit that Ubuntu (or Debian derivatives) achieve by disabling root user?

Everywhere I read, it says to prevent unintentional damages for inexperienced users. I want to know what exactly, since sudo can execute all commands (that I know/use).

So in what case root can cause damage whereas sudo can't?

PS: I know how sudo works.

share|improve this question
    
possible duplicate of Why is there no option to login as root? – Takkat May 11 '12 at 10:51
up vote 23 down vote accepted

So in what case root can cause damage whereas sudo can't?

Since you must usually invoke sudo each time you want to do something that requires privileges, the reasoning is that you will "think before you leap", i.e. not just stick sudo in front of something without thinking for a second what the command you're running is going to do.

With su on the other hand, once you're in, you're in. You have carte blanche (an open license) to do anything and everything, and the reasoning is you might forget for a moment that you have those privileges and if you're unlucky, execute something that will seriously affect/damage your system -- if you did not have su privileges, the command wouldn't have done anything serious.

share|improve this answer
5  
The "think before you leap" logic is as naive as thinking users will stop to think when shown a dialog box that says "Do you really want to install TrashTheComputer.Virus: Yes/no?" will reduce malware infection rates. – Dan Neely May 11 '12 at 14:42
7  
@DanNeely - I don't think so. I type a lot of commands, and most of them don't require sudo, so I don't use it. When I do use it, it gives me a moment of pause. Yes, I'm speaking as a programmer, not an average user, but then again, average users don't use the command line. – Nathan Long May 11 '12 at 15:20
    
@NathanLong not quite true with Linux, the reason this question exists shows an "average user" not understanding why to use sudo over su. Too often, people say "use sudo because it's safer than su" - which is naive to think as it isn't any safer at all. To forget you used su is no excuse, that's just down-right incompetence if you run a command as root accidentally. – ash Jan 28 at 16:08
    
@ash I still say an average user would not be asking about the comparative security implications of two methods of escalating user privilege. In point of fact, OP has questions on StackOverflow. But OP aside, remembering what you did 15 seconds ago is easier than remembering what you did yesterday, and you could easily have a terminal session spanning days. So yes, it's on you to not forget when you use su, but personally I'd rather not set up bombs than assume I'll remember to disarm them. – Nathan Long Jan 28 at 19:22
    
@NathanLong then you're incompetent, leaving a terminal open under the root user any longer than necessary for your task is more of a concern than accidentally running a command thinking you were not root. – ash Jan 28 at 21:17

IMO the major advantages of sudo over su are that sudo has superior logging of what commands were run and sudo gives finer control over what users can do.

su is all or none, but sudo can be configured to allow access to some, but not all commands.

See https://help.ubuntu.com/community/RootSudo for a more complete discussion, including advantages and disadvantages.

share|improve this answer

su -

When logged in as root, any task you start, action you trigger, or random event caused by visiting a certain website, etc. .. will run as super-user.

sudo

When you invoke sudo, as you run a command, only that command will run as super-user.

You will be asked for your password, before the command is executed. So user-interaction by you is also required.

Attempts to invoke sudo can also be logged.

share|improve this answer
2  
Indeed, it asks for the current user's password, which makes it easier to manage the root password. If an account is removed from the system, the root password does not need to be reset. Even better, the root account doesn't even require a password at all, so the root account cannot get compromised through brute forcing it. – jippie May 11 '12 at 10:54
    
@jippie general good practice states to remove/block/invalidate the root password and only allow access via sudo su. whilst the hyphen - is a flag accepted by su and treats your shell as if you logged in as the user (runs a different set of environment files i.e. .bashrc/.profile) – ash Jan 28 at 16:13

It is about user/password management for sysadmins.

If you have multiple users, they should all have separate accounts and should be able to be tracked using those accounts. This means that people can't hide their identity. Also, if you need to revoke a specific users permissions you don't also have to reset the root password for that same user. To give every person in an environment with more than 2 admins the root password makes for a nightmare when one person quits. You must not only change it, but communicate it, etc. All this stuff also has to happen when one of them has a laptop stolen or stuff like that. One account with one password per person makes administration simpler. It is similar to the philosophy behind why each service should have its own account. If one account is compromised, you don't have to reconfigure another dozen services (such as backup tasks) to use a different account.

I also find it personally convenient not to have yet another password to keep track of, lose and have compromised. On RHEL I specifically disable the root account after configuring sudo so I don't have to track it. Once in awhile a user b0rks the sudo file, but that's fixable in single-user mode. (Naturally, it is usually a production machine.)

NOTE: 'sudo bash' will allow you to skip typing sudo for each command...

share|improve this answer
    
I always sudo mc :D – Rony May 16 '12 at 3:18
    
The only answer on here worthy of up voting, clearly answers the question without further disambiguating the question or misleading people into a false sense on information. – ash Jan 28 at 16:17

In addition there are logging considerations to consider between sudo and su. Being su simply does everything as root with no entry other than one line in the auth log saying you became root.

Sudo on the other hand - always gets logged as your user ID with escalated priveleesw.

share|improve this answer

I think first, we need to look into what su and sudo actually are

su - stands for Substitute User. You use this to switch to a shell as another user using that user's password. Commonly used with root. Does not require a password when executed as root.

sudo - allows a permitted user to execute a specified command as another user. Also commonly used with root. However, this allows you to specifically manage what commands may be executed as another use. (For instance, you could give a user the ability to run an init.d script but nothing else.)

Note, you can always run sudo su or sudo -i and that will give you a root shell. However, no root password means no logging in directly as root... which means no one can break into that user.

EDIT: so maybe this answer your looking for is: not having a root password forces you to use sudo, which in turn naturally aligns you with the sudo philosophy which suggests you to enforce greater control over the actions run as root.

share|improve this answer
    
I wrote this myself.... – user606723 May 11 '12 at 18:01

Usually, logging in as su is easier when performing administrative tasks. However, there is at least one exception: when file ownership matters. If you need a user to be the owner of a file, then log in as that user and use sudo to donwload or copy files. Simple examples are bookmark and wallpaper files. If a user does not own the file, a Firefox "Restore" bookmarks "From File" will fail. When you set a desktop wallpaper, it may not work unless you own the file. Sometimes you can just set privileges or enable as an executable file, but some settings or programs fail if you are not the owner of a file.

share|improve this answer
    
You log in as root and use Firefox to browse the web? I think this is the reason for disabling the root account. It eliminates the possibility of just logging in as root for daily use. – adempewolff May 30 '12 at 10:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.