Help, I Use Ubuntu and There's No "su"! - gHacks Tech News

Help, I Use Ubuntu and There's No "su"!

So you've just installed Ubuntu and you're ready to tackle all those great administrative tasks you've heard about with Linux. You've even been briefly tempted to try the old rm -rf / command just to see if it's really true that it will wipe away your entire computer as you watch it happen. Only problem is...all those glorious commands you've heard of required "super user" (or su) access. No matter how you try you can't seem to remember adding an administrative password and your standard password doesn't gain you access to the root user.

Relax. Ubuntu was created so that "su" access wasn't necessary. Instead Ubuntu employes the "sudo" utility which adds the standard user to the administrative group. Why did they do this? Simple. Ubuntu's goal is to make their distribution the most user-friendly available. To that end the developers felt it necessary to "remove" the root user because the average user had little to no experience with such a beast. The average user certainly didn't have to have "root" privileges to get around in the Windows operating system. Ubuntu figured this was the way to go. There were two ways around this - make the standard user a root user or just emply sudo and create an administrative group the standard user would belong to. Now the standard user could undertake admin tasks without having to understand the concept of a standard user versus a root user.

When you install Ubuntu you created a user and that user has a password. To handle most any "administrative" task all they have to do is use the "sudo" command so they can run commands as a different (in this case the administrative) user.

So if you want to issue a command that requires administrative access you would issue it by way of the sudo command like so:

sudo ADMIN_TASK

Where ADMIN_TASK is the actual administrative task you want to run. When you hit enter you will be asked for your password, at which point you will enter your standard user password.

But What About "su"?

I have run into instances where I have wanted to have actual root access. Although I don't really recommend this (It is actually best to stick with the setup Ubuntu has created), you can create a root password by issuing the command:

sudo passwd root

When you press enter you will be prompted (twice) for a new password. Once you enter the password the second time your root password will be ready to use.

/etc/sudoers

The /etc/sudoers file is where you configure sudo. This file shouldn't really be monkied with as the default should work perfectly for you. There is one particular line you should definitely avoid (of course I have to point it out so you will know which one to avoid.) Take a look at this line:

# %sudo ALL=NOPASSWD: ALL

You probably have a good guess as to what that line would do if it were uncommented. Allow the sudo user access to root privileges without having to use a password. This should remain commented out so this option isn't available.

Final Thoughts

The Ubuntu distribution has created one of the most user-friendly setups in Linux land. Taking advantage of sudo is one of the many ways Ubuntu achieves such a state. Understanding the sudo system will keep new Ubuntu users from pulling out their hair as they attempt to gain root privileges. New users? Nothing to see here...just go about your business. ;-)

Advertisement

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:


Previous Post: «
Next Post: »

Comments

  1. Richard said on April 1, 2009 at 8:50 pm
    Reply

    What about the ever so popular ‘sudo su’ command:D

    and another nice command is ofcourse

    ‘chmod ugo= -R /’ and enjoy;)

  2. morgan said on April 2, 2009 at 12:38 pm
    Reply

    Ever better – if you want true root

    type

    sudo passwd root

    – enter password
    – then you can su

  3. morgan said on April 2, 2009 at 12:53 pm
    Reply

    … I should have mentioned….

    When you use

    sudo passwd root

    – it asks for a password – first its your normal sudo pass , then it asks you for the new root (su) password

    – it confused me

  4. Michele said on April 5, 2009 at 3:23 pm
    Reply

    If you want root prompt you don’t need to change root password, just use “sudo -s”.

    (03:24 PM) [mb@servertwo]:~
    $ id
    uid=1000(mb) gid=1000(mb)
    (03:24 PM) [mb@servertwo]:~
    $ sudo -s
    (03:24 PM) [root@servertwo]:~
    # id
    uid=0(root) gid=0(root)

  5. Graeme said on April 17, 2011 at 10:13 pm
    Reply

    Thanks.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.