When you use the sudo command to gain superuser (administrator) privileges, you will be prompted to enter a password. You may notice that when executing further commands using the Sudo console, you will not need to re-enter the administrator password again.

You do not need to re-enter, because the system has a configuration file in which the session time is set, after how many minutes you need to re-request the administrator password and in this material, I will try to help you figure out how to change this timeout or disable it altogether.

Change Sudo Session Password Timeout

We need to open the file “/etc/sudoers” for editing, in which we write the timeout we need. To get started, open a terminal.

Type the following command in Terminal and press Enter:

sudo nano /etc/sudoers

After entering the administrator password, the sudoers configuration file we need will open in the nano system text editor, I hope many are familiar with this text editor, use the arrow keys (up, down, left and right) to navigate through the lines.

Find the line below:

Defaults env_reset
How to Change Sudo Session Password Timeout in macOS?

Which we need to replace with the following:

Defaults env_reset, timestamp_timeout=x
How to Change Sudo Session Password Timeout in macOS?

In this example, the symbol “x” we need to replace the number of minutes after which the current session ends and the next time you execute commands in the terminal, you will be asked to enter the administrator password again.

After editing:

Press “Ctrl” + “O” (Save Changes), then “Ctrl” + “X” (Exit).

Read more: How to Detect If Someone Was Using Your Mac?

We can completely disable the password request by replacing the “x” parameter with “-1”, after which the password request will be disabled and after executing the sudo command, you will automatically be logged in as the superuser, this is highly discouraged, situations are different and sometimes because Very extended privileges can ruin the system, it is better to leave the password request and not disable it.


As you can see, I set the session timeout to 5 minutes, which is quite enough, of course you can set 10 and 20 minutes, as you please. After making the changes above, to make the edits work, you need to log in to the terminal by executing the exit command several times or clearing the password cache that is entered using the sudo command by executing the command sudo -k, after entering the password you will be prompted immediately even if the session period has not expired.

Keep in mind that this method of changing, works the same way in Linux systems.

It’s the best time to ask questions and give us your feedback in comments.


Hi there! My Name is Vincent Lago! My goal is to share insightful reviews, guides, and manuals for people looking to know more about current solutions for Apple hardware and OS. I have years of technological background knowledge including owning a custom iMacs & PCs which was using for different types of business. And now, I want to share my experience with you.

Write A Comment