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.

2
  • 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? Feb 5, 2019 at 16:48
  • apt-get commands run as expected (with pw-prompt). If I run it with ./ it behaves the same.
    – izlin
    Feb 6, 2019 at 7:54

2 Answers 2

1

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

1
  • Yep! I just had the same problem (not inside a script, just executing a command) and a terminal restart fixed it. Not sure what caused it. Oct 15, 2019 at 22:37
-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

3
  • 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, 2019 at 12:54
  • 2
    I don't think there would be a password prompt in that case Feb 5, 2019 at 14:15
  • It is the first thing I execute in the terminal, so there is no sudo from earier.
    – izlin
    Feb 6, 2019 at 7:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .