4

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?

Chris
  • 41

2 Answers2

4

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

roadmr
  • 34,222
  • 9
  • 81
  • 93
0

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

  • "I don't want this because then, eg., many files and folders get created that can't be deleted without root access" – Gauthier Feb 12 '15 at 13:25
  • The commands will have root access. The script is ran as rot, so it's child processes (the commands in the script) will be spawned and run as root. – ActionParsnip Jun 23 '16 at 12:11