6

I am on a linux virtual machine and I'm trying to run the command sudo synaptic & which should start synaptic in the background. However, it doesn't ask for the password and the program doesn't seem to start. I have not typed my password earlier, as running any other command withouth the & at the end ask for my password. What is the problem?

isedev
  • 16,514
  • 3
  • 51
  • 58
user2966143
  • 63
  • 1
  • 4
  • possible duplicate of [pass password to su/sudo/ssh](http://stackoverflow.com/questions/233217/pass-password-to-su-sudo-ssh) – Sam Sep 29 '14 at 22:26
  • Did you log in your virtual machine as "root"? If so, you are running with root privilege, and be careful with that. – 4af2e9eb6 Sep 29 '14 at 22:26
  • Trying to background something – *anything* – with sudo immediately raises a couple of red flags. What's the actual problem you're trying to solve? Did you try running it as a service managed by your supervisor suite (systemd, runit, OpenRC or whatever else your system is using)? – datenwolf May 10 '21 at 14:54

3 Answers3

15

You can run sudo bash -c 'synaptic &'

Thyrst'
  • 1,394
  • 2
  • 17
  • 25
3

The problem is that the sudo command itself is being run in the background. As a result, it will be stopped (SIGSTOP) when it tries to access the standard input to read the password.

A simple solution is to create a shell script to run synaptic & and then sudo the script in the foreground (i.e. without &).

isedev
  • 16,514
  • 3
  • 51
  • 58
0

sudo --help says about option -b

-b, --background              run command in the background

This worked for me

sudo -b su -c "command what you want to run"
Anurag_BEHS
  • 1,142
  • 1
  • 18
  • 34