If I do sudo <command> and enter the password, my Debian Squeeze remembers the fact I passed the password and never asks for it for i.e. 15 minutes.

But if I do sudo -i and then exit, the system does not remembers the password and asks for it all over again every time I use sudo -i. Doing just once sudo <command> makes the system not ask for password even for a next sudo -i.

Here are the scenarios I've described above:

First one:

  1. login (by SSH),
  2. sudo <command>: system's asking for the password,
  3. sudo -i: system is not asking for the password.

Second one:

  1. login (by SSH),
  2. sudo -i: system's asking for the password,
  3. exit
  4. sudo -i: system's again asking for the password.

Doing something beetween 2. and 3. makes the system remember the password.

What is the reason of such a behaviour? Is it possible to make the system remember the password (fact I passed it) also after using sudo -i?

  • If I do sudo -i, immediately exit or logout and then again sudo -i, the password is properly remembered and the second sudo command doesn't ask for it. Apr 16, 2014 at 21:36

1 Answer 1


From the sudoers(5) man page:

As a special case, if sudo's -i option (initial login) is specified, sudoers will initialize the environment regardless of the value of env_reset. The DISPLAY, PATH and TERM variables remain unchanged; HOME, MAIL, SHELL, USER, and LOGNAME are set based on the target user. On Linux and AIX systems the contents of /etc/environment are also included. All other environment variables are removed

The fact that USER is being set, would likely mean that regardless of your passwd success, that counter is getting reset.

There are other knowledge points in that documentation you should be aware of as well.

  • And what about the fact "Doing sth beetween 2. and 3. makes the system remember the password."? Doing sth changes the 'counter'? Jun 4, 2013 at 17:13
  • I am sorry, I don't know what 'sth' means. But if it means 'steps' then then why does it not ask for the password between the steps? Because step 2 you are not using the -i and so it remembers the password, in the third step, then the rules apply according to the documentation. Once the exit is done, you are changing environments by changing the shell.
    – vgoff
    Jun 7, 2013 at 5:43
  • sth = something Jun 7, 2013 at 10:04
  • Doesn't seem to answer the question at all, even though accepted. Apr 16, 2014 at 21:35
  • Doesn't answer which question? There were two.
    – vgoff
    Apr 18, 2014 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .