How to Change Sudo Timeout Period in Linux

How to Change Sudo Timeout Period in Linux

Linux is a powerful operating system with rich controls for permissions and security. When users need to run tasks and commands that require administrative or superuser privileges, they generally add sudo keyword before their command. This gives them superuser privileges for 5-15 minutes, by default. After that, they lose their superuser privileges and need to use sudo keyword in case they need to run commands & programs which require superuser privileges. This can be quite annoying if you want to work long durations with superuser privileges. In such cases, it is advisable to simply change the sudo timeout period in Linux. In this article, we will learn how to do this.

How to Change Sudo Timeout Period in Linux

When you run a command or program by adding sudo keyword at its beginning, then Linux starts a sudo session for you and then runs your command inside it. This session gives you superuser permissions but lasts for 5 minutes on most Linux systems. On Ubuntu/Debian systems, it can last for 15 minutes.

When you use sudo keyword in your command, you need to enter your root password just once before entering the session. Once the timeout period of 5/15 minutes is over, you will be asked to enter root password once again.

But when you are using your Linux session alone on your workstation or laptop, and know that someone else is not going to use it, it is okay to increase sudo timeout period.

The following steps can be used in all Linux distributions irrespective of their version, release, package manager or desktop environment.

First we need to open the sudo file which contains a list of sudo permissions. Open terminal and run the following command.

$ sudo visudo

Look for the following line.

Defaults env_reset

Below this line type the following line. Replace <time-in-minutes> with the new timeout value.

Defaults timestamp_timeout=<time-in-minutes>

For example, if you want to increase timeout value to 30 minutes, type the following.

Defaults timestamp_timeout=30

Save and close the file. That’s it. Now your sudo timeout value will be increased to 30 minutes.

In this article, we have learnt how to change sudo timeout value in Linux.

Also read:

How to Initialize JavaScript Date to Specific Time zone
How to Install PuTTy on Linux
How to Print Python List as Tables
How to Get Difference Between JavaScript Arrays
How to Fix NGINX 403 Access Forbidden for Static Files

Leave a Reply

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