Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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:

timestamp_timeout
                       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
                       respectively.
share|improve this answer
add comment

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

share|improve this answer
add comment

'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 :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.