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.
Detailed instructions for opening a command line / terminal can be found here.
sudo temporarily grants administrative privileges for 15 minutes. This means the first time you run
sudo you will be prompted for your password. For the next 15 minutes, you can run
sudo <command> without having to enter a password.
This should be fine for most users because the average user is likely to drop down to a command line to run an administrative command or two rarely.
1) Open a terminal using
Ctrl + Alt + T
2) Enter the following command:
3) Enter your password:
Note: when you type your password, nothing will happen on the screen. This is normal. As a security feature, Linux does not echo back any indication of the characters you are typing in.
This will bring up the
sudo configuration file in the
nano editor. Note: in other versions of Linux (or if Ubuntu has been modified), the configuration file may be opened with a different editor – in which case, you will need to Google for instructions on using that editor.
visudo does more than just open the
sudo configuration file with the
nano editor. It also checks to ensure the configuration file is correct (i.e. it will not let you edit the file and make it invalid). Note: you can still edit the file, so
sudo becomes unusable, but the configuration file is valid.
4) Locate the line
Defaults (highlighted in yellow) and navigate to the end of it using the arrow / cursor keys on your keyboard. Add the following:
The number tells
sudo the number of minutes it should grant administrator privileges in this session.
A value of 0 tells
sudo to always prompt for a password. Personally, this is the only setting that makes sense for me because if you are momentarily away from your computer, no one else can accidentally (or intentionally) run an administrative command while your
sudo privilege is still active.
A positive number tells
sudo to grant administrative privileges that that number of minutes. The number must be a whole number: 5, 15, 42, etc. Number like 3.1415 are not valid.
A negative number tells
sudo to permanently grant administrative privileges during that session. The only use I see for this is if you want to have to type
sudo before administrative commands, but not have to enter the password for subsequent commands.
5) Save your changes by pressing
Ctrl + O:
You will be prompted to save the file as
6) Press Enter to write the changes.
7) Observe that the changes were written:
visudo by pressing
Ctrl + X.
Starting a new command line session should pick up the changes you just made.