I was wondering if there is a way to enter in my admin password someplace just once and keep it for my entire time logged in. I hate having to type sudo command-name* every five seconds, or typing in the password every time the system wants to perform a task. Is there a way to just enter it once for my session and have it be remembered.

I know this is bad practice, but this is on a VM that I don't care about.

4 Answers 4


sudo su will work - You will have a shell as root until you close it, as will giving root a password using passwd root and logging in directly as root. Both of these are heavily frowned upon for many reasons that have been listed here the dozens of other times this question has been asked.


You can increase the time you have between needing to re-enter your password:

sudo visudo

will edit your /etc/sudoers file and you can add the timestamp_timeout option for your username.

From man sudoers:

                       Number of minutes that can elapse before sudo will ask
                       for a passwd again.  The default is 15.  Set this to 0
                       to always prompt for a password.  If set to a value
                       less than 0 the user's timestamp will never expire.
                       This can be used to allow users to create or delete
                       their own timestamps via sudo -v and sudo -k

'sudo -i' will drop you into a shell as root with root's environment.

If you truly don't care about the machine, an extremely bad practice is to disable passwords completely for sudo. To do this, edit your sudo config:

  • execute 'visudo'
  • insert 'username ALL=NOPASSWD:ALL' to the very bottom of the file, replacing 'username' with your username

Definitely do not do this on any machines unless your absolutely insane :)


sudo -i is the right way to do it with sudo, so you get nice environment variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy