Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2016  / 3 Years ago, fri, may 28, 2021, 1:09:28

I am making a script that will update my system (and do some other things, but that doesn't matter). I want the script to run sudo apt-get update and sudo apt-get dist-upgrade --yes automatically. I use --yes so I won't have to choose yes when it runs; it upgrades all packages automatically without me having to do anything. That said, I want to put my password in the script somehow so I won't have to type in my password when I run it either, probably with an argument or something. You know, something I can put at the end like sudo apt-get update --passwd MYPASSWORDHERE. I have tried that and it doesn't work, but that's an example of what I want. What argument (--passwd or --password or something) do I put at the end to do this?


More From » bash

 Answers
4

Sudo doesn't behave that way, for security reasons. You can echo the password to sudo using the -s option, but I don't suggest it. Even if you protect your script from other users, they can still see your parameters using e.g. ps -ef.



I think your problem is better solved by installing the unattended-upgrades package.


[#24186] Saturday, May 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elopingapo

Total Points: 206
Total Questions: 110
Total Answers: 114

Location: Guam
Member since Tue, Nov 29, 2022
1 Year ago
elopingapo questions
Fri, Sep 10, 21, 17:52, 3 Years ago
Tue, May 24, 22, 00:42, 2 Years ago
Sat, Apr 23, 22, 03:16, 2 Years ago
Fri, Jan 13, 23, 06:41, 1 Year ago
;