Complete, Concrete, Concise

Practical information without the bloat

Ubuntu 13.04 – How to Change the Timout Period for sudo

This tutorial is for Ubuntu 13.04.

It is probably 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.

By default, sudo temporarily grants administrative privileges for 15 minutes. This means the first time you run sudo you will be prompted for your password. Then, for the next 15 minutes, you can run sudo <command> without having to re-enter your password.

This should be fine for most users because the average user probably rarely drops to a command line to run an administrative command or two.

1) Open a terminal using Ctrl + Alt + T:

2) Enter the following command:

sudo visudo

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.

The command 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 (technically speaking) valid.

4) Locate the line Defaults (highlighted in yellow) and navigate to the end of it using the arrow / cursor keys on your keyboard (your mouse will not work). Add the following:


The number tells sudo for many 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 /etc/sudoers.tmp.

6) Press Enter to write the changes.

7) Observe that the changes were written:

8) Exit visudo by pressing Ctrl + X.

Starting a new command line session should pick up the changes you just made.

%d bloggers like this: