Tuesday, May 7, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 550  / 2 Years ago, tue, september 27, 2022, 4:35:59

Please consider this code:



alias fast='echo "password" | sudo -S apt-get update && sudo -S apt-get upgrade'


I have not yet had a problem using it but is it possible that if the first step, apt-get update takes a very long time, the password would lapse by the time the apt-get upgrade commands finally runs?


More From » command-line

 Answers
5

but is it possible that if the first step, apt-get update takes a very long time, the password would lapse by the time the apt-get upgrade commands finally runs?




The answer is yes, sudo could time out and ask you for the password again.




  • Another method which is still insecure (but at least it does not require you writing a password to file) is described at How to run an application using sudo without a password?


  • If you want to proceed with an approach where you write your password down in cleartext, consider chaining the command together and use sh to execute it:



    echo password | sudo sh -c "apt-get update && apt-get upgrade"


    In this way, sudo requires you to enter the password only once, and sh is executed as root. Then any programs run by sh are automatically running as root.


  • Finally, you can pass the password twice to the separate programs:



    echo password | sudo apt-get update && echo password | sudo apt-get upgrade


[#37553] Tuesday, September 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
guialk

Total Points: 300
Total Questions: 144
Total Answers: 121

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
;