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?
Asked
Active
Viewed 8,325 times
6
![](../../users/profiles/2009616.webp)
isedev
- 16,514
- 3
- 51
- 58
![](../../users/profiles/2966143.webp)
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 Answers
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 &
).
![](../../users/profiles/2009616.webp)
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"
![](../../users/profiles/4534414.webp)
Anurag_BEHS
- 1,142
- 1
- 18
- 34