Ubuntu and sudo

Ubuntu disables access to the root account by default, for reasons which have never been particularly clear to me. They deem it preferable to give users sudo access, which is all well and good, but typing a series of commands, all prefixed by ‘sudo’, can be very tedious.

Fortunately, there are a few ways around this.

The first is to use a super user shell. From a terminal or console, type:
sudo bash
This will give you a shell with full root access, and save you needlessly typing ‘sudo’. (You can, of course, use other shell flavours, like zsh or csh if you prefer.)

A similar method is to run the ‘su’ command with sudo, thusly:
sudo su
which will also give you a shell with full root access, according to root’s preferred shell.

The third method is to alter the password protecting the root account. To do this, from a terminal or console, type:
sudo passwd root
and enter a password for the root user. Now you will be able to log on to consoles (and, if you’re that way inclined, X sessions) as root.

Comments

One response to “Ubuntu and sudo”

  1. Nicholas van Oudtshoorn Avatar
    Nicholas van Oudtshoorn

    This is one of the reasons I don’t use Ubuntu. Although I suppose it does make things easier for the average person on the street.

    By the way, it’s “best practise” to issue “su -” rather than plain old “su” (or, in ubuntu: “sudo su -“. The dash at the end forces root’s shell configuration to be loaded. It also changes the current directory to root’s home directory.

    This way you get all of the extra shell settings etc. you use as the super user. (hmm – a few aliases might come in useful as root!)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.