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.

izlin
  • 181
  • 1
  • 2
  • 9
  • 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 05 '19 at 16:48
  • apt-get commands run as expected (with pw-prompt). If I run it with ./ it behaves the same. – izlin Feb 06 '19 at 07:54

2 Answers2

1

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

Niklas
  • 467
schartz
  • 119