Maximize Sudo Session Duration in Linux

This guide intends to teach you to Maximize or Increase the Sudo Session Duration in Linux. In Linux, a sudo session duration refers to the length of time during which a user can execute commands with admin privileges using the sudo command without being prompted to re-enter their password. By default, this duration is set to 15 minutes. After this, the user will need to re-authenticate with the password to continue executing sudo commands. If you want to enhance this time, you can follow the rest of the article.

Simply Learn to Maximize Sudo Session Duration in Linux

Before you start to enhance the sudo session timeout, you need to log in to your Linux server as a non-root user with sudo privileges. For this purpose, you can visit the Orcacore website and search for Initial Setup Guides.

Then, follow the steps below to complete this guide.

Display Current Sudo Session Time

As you know, the default value is set in the sudoers configuration file which is located at /etc/sudoers. To check the current session time, you can use the following command:

sudo visudo 

In the file, look for the following line:

Defaults        env_reset,timestamp_timeout=15

The number next to the timestamp_timeout option is your default session time. If you don’t see this line in your file, means your default session is 15.

Once you check the file, exit and follow the steps below.

Increasing Sudo Session Duration

At this point, you can simply open the visudo file with the following command:

sudo visudo

Find the following line and set your desired value. If the line doesn’t exist, you can add it manually:

Defaults        env_reset,timestamp_timeout=30

When you are done, save and close the file. This example will increase your time session to 30 minutes.

Note: If you set a value of 0, you’ll have to enter your password every time you use sudo. If you set a negative value like -1, your sudo session will never expire.


With these steps, you’ve successfully maximized the sudo session duration in Linux. Keep in mind that increasing the session duration too much may cause security risks, so balance convenience with security considerations. Hope you enjoy it.

Also, you may like to read the following articles:

Use the arp command in Linux Networking

Symbolic Links Guide in Linux For Beginners

The Ultimate smartctl Hard Drive Monitoring Guide on Linux

Spaces in Filename on Linux with Examples

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!