Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am writing a script to download build and install a bunch of packages. Building sometimes takes a while, and installing requires root priviledges:

make; sudo make install

What happens alot is that when a build takes a while I need to keep entering my password. I want to be able to only enter it once. I could call the script with root access, but then (as I understand it) every call it makes will be with root priviledges. I don't want this because then, eg., many files and folders get created that can't be deleted without root access.

so what is the best way to do this?

share|improve this question

2 Answers 2

Use the timestamp_timeout parameter. Use visudo to edit the sudoers file:

sudo visudo

and modify the defaults line so it looks like this:

Defaults   env_reset,timestamp_timeout=60

this will keep your password for 60 minutes.

Modify this time as desired :)

share|improve this answer

The script can contain sudo calls themselves. If you then run the script with sudo it will cover all sudos in the script and should be ok

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.