Make Sudo Sessions Last Longer In Linux

Make Sudo Sessions Last Longer In Linux

When you run sudo in Ubuntu, your administrative privileges last for 15 minutes by default so you don’t have to type in your password with every command. If that is too long or short for your tastes, you can change it with a simple tweak.

We recently showed you how to make your sudo passwords visible, and I discovered another handy tip in that exploration. If you’d rather not type in your password every 15 minutes (or if you’d rather your computer prompt you more often for security reasons), you can change this timeout value by editing the sudoers settings file. Here’s how:

  1. Run the following command in a Terminal: sudo visudo
  2. Scroll down to the line that looks like this:

    Defaults env_reset
    and change it to this:

    Defaults env_reset,timestamp_timeout=30

    Change 30 to the time, in minutes, that you want it to wait before it times out. You can also change it to 0 if you want a password prompt every time you run sudo, or -1 if you never want a password prompt (although we don’t recommend this).

  3. Press Ctrl+X to finish editing, Y to save changes, and press Enter to exit if you’re on Ubuntu. Other Linux distros may have different commands depending on the default editor.

We haven’t tested this with other Linux distros, but it should work in most others as well. Hit the link to read more.

Change the Sudo Password Timeout in Ubuntu [Make Tech Easier]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments