Ubuntu 12.04 – How to Run a Shell / Command Line / Terminal with root Privilege / Access

This tutorial is for Ubuntu 12.04.

It should be the same for other versions of Ubuntu and (probably) most other Linux distributions, but no guarantee is made./p>

Detailed instructions for opening a command line / terminal can be found here.

When you open a terminal in Ubuntu, you do not have administrative privileges. This means that there are some operations you cannot perform at the terminal.

Ubuntu provides the sudo command which temporarily grants you administrative privilege. However, you still have to type sudo before each administrative command you want to perform.

If you want to live dangerously and have full root access while at the terminal, enter the following command in the terminal:

sudo bash

After entering your password, you now be running with full root privilege at the command line:

Note: in order for this to work, you need to be a user who has the right to run sudo. In general, most users of Ubuntu have this right. However, user accounts can be created that do not have this right.

How it Works

Because some commands are potentially dangerous, unless you are root you are not allowed to run them. Using the sudo command temporarily elevates your status to root and allows you to run these commands.

When you run a terminal, it has the same privilege as the current user.

By running sudo bash you start another copy of the bash shell. However, you because you started it with sudo it runs with root privilege.

What is commonly called a terminal or command line is, in fact, a shell. There are many types of shells, bash is the default one with Ubuntu.

WARNING: running as root is a good way to mess up your system if you are not careful because there are no checks in place to prevent you from making catastrophic changes to your system.

I grant that by using the sudo command you can also irretrievably damage your system, but at least you had to type sudo (and possibly a password) before doing anything.