Ubuntu – Why doesn’t the ‘su’ command work in Ubuntu but does in other Linux distros?

command linesusudo

When I type the su command in a terminal I get

 su: Authentication failure

Why doesn't this work in Ubuntu? I have tried this command in another Linux distro (Parrot OS) and it does work.

Best Answer

  • Because in Ubuntu, by default, root has no password.

    Without arguments, su means "switch user to root" and to do that you have to enter root's password, not your own. Unless you give root a password, it doesn't have one, so you can't literally log in as root.

    Here's some background:

    In the Unix world, there has always been a larger division between regular users and administrators, owing to the multiuser heritage of Unix. The approach taken in Unix is to grant superuser privileges only when needed. To do this, the su and sudo commands are commonly used.

    Up until a few years ago, most Linux distributions relied on su for this purpose. su didn't require the configuration that sudo required, and having a root account is traditional in Unix. This introduced a problem. Users were tempted to operate as root unnecessarily. In fact, some users operated their systems as the root user exclusively, since it does away with all those annoying “permission denied” messages. This is how you reduce the security of a Linux system to that of a Windows system. Not a good idea.

    When Ubuntu was introduced, its creators took a different tack. By default, Ubuntu disables logins to the root account (by failing to set a password for the account), and instead uses sudo to grant superuser privileges. The initial user account is granted full access to superuser privileges via sudo and may grant similar powers to subsequent user accounts.

    ~ The Linux Command Line

    You can use su to switch user, if you know the password of the user to switch to, for example, I can su pixie to log in as my backup user.

    Normally though, you should use sudo and your own password to authenticate, or to start a root shell, use sudo -i