I've been trying to create a script that runs sudo apt-get update
and sudo apt-get autoremove
whenever I log in. It goes like this:
#!/bin/bash
(sudo apt-get update)
(sudo apt-get autoremove)
But whenever I run the script it freezes my computer. I'm assuming it's because it's waiting for the script to supply a password. Would it work if I added PASSWD:mypassword
after the commands like this:
#!/bin/bash
(sudo apt-get update)PASSWD:mypassword
(sudo apt-get autoremove)PASSWD:mypassword
or is there something else I should do? Is there even a way? If so please tell me!
/etc/apt/apt.conf.d/50unattended-upgrades
) is to allow automatic runs ofautoremove
. – muru Apr 21 '15 at 18:01sudo apt-get
without a password. Create a file named/etc/sudoers.d/willem
containingwillem ALL = NOPASSWD: /usr/bin/apt-get
-- assuming "willem" is your username – glenn jackman Apr 21 '15 at 18:03sudo visudo -f /etc/sudoers.d/willem
to create/edit that file – glenn jackman Apr 22 '15 at 21:56