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:
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.
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.
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. ;-)
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 (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.