1

I have the following little script:

#!/bin/bash
cd ~

thunderbird &
firefox &

sudo apt-get update
sudo apt-get upgrade

It worked for the last two years, but for a few days it skips the password prompt. Output (without any actions from me, except starting the script):

me@UBUNTU:~$ sh goodmorningscript.sh 
[sudo] password for me: 
[sudo] password for me: 
me@UBUNTU:~$

It just runs through, without stopping and waiting on the password prompt. I don't want a solution without entering my password.

What could have caused my Ubuntu to skip the prompt and how can I solve it?

Note: If I manually enter sudo commands, the prompt works as expected.


GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)

Ubuntu 18.04.1 LTS


I found one possible solution, that works in my case. If the sudo command comes before the ones with &, the password prompt works as expected:

#!/bin/bash
cd ~

sudo apt-get update
sudo apt-get upgrade

thunderbird &
firefox &

I still don't know why, but maybe this helps.

  • 1
    Do the apt-get commands actually run? or do you just see two password prompts and then nothing? Is the behavior different if you run the script directly ./goodmorningscript.sh rather than via sh? – steeldriver Feb 5 at 16:48
  • apt-get commands run as expected (with pw-prompt). If I run it with ./ it behaves the same. – izlin Feb 6 at 7:54
0

I had the same problem when using the terminal. Just restarting the terminal fixed it for me.

-1

It is most likely that you have used sudo (with some other command) before executing your script.

sudo effect stays for a while (default 15 minutes). Try waiting for a couple of minutes. Or close and reopen your terminal and try again.

If the same behaviour persists a bit more information will be required in that case. Run sudo -l and paste the output here

  • 1
    I think this would be better suited for a comment at this point, as we don't yet have enough information... – j-money Feb 5 at 12:54
  • 2
    I don't think there would be a password prompt in that case – steeldriver Feb 5 at 14:15
  • It is the first thing I execute in the terminal, so there is no sudo from earier. – izlin Feb 6 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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