[ALUG] sudo &

Mark Rogers mark at more-solutions.co.uk
Thu Jun 8 13:08:12 BST 2017

On 8 June 2017 at 12:40, Brett Parker <iDunno at sommitrealweird.co.uk> wrote:
> So, how about looking at the magical man page... or even sudo --help...

Fair point (I started with Google and didn't find many options, but
did find this one after my post). However it's not equivalent as it
then doesn't allow the jobs to be managed in the same way once
started, and that rules it out for me.

As to the other suggestions: Yes, editing sudoers will work for
specific cases but I don't want to avoid the password security (just
avoid it being hidden in the background).

sudo myapp && bg
.. looks like a good one to play with, but surely bg won't run until
myapp completed?.

To expand on the reason I asked: Today I ran out of disk space and
started going through a tidy up. I found some large directories
(unused virtual machines that I don't want to throw away but don't
really need either) that I wanted to compress. So I used:
    vm=vm1 ; sudo tar -cjf $vm.tar.bz2 --remove-files $vm &
.. which worked fine as I had already done some tasks with sudo by
that point so no password was needed.

a while later I came back (after it had finished), edited the command
to backup vm2, hit enter and got on with other tasks again. Of-course
my sudo session had timed out, and whilst nothing looked any different
it was sat there doing nothing and I didn't realise for a few hours,
when "jobs" showed me that the task was stopped.

In this scenario, unless I enable password-less sudo, /etc/sudoers doesn't help.

I did find one useful suggestion after more Googling that created a
"sudobg" alias[1] which looks like the best option so far.

[1] https://askubuntu.com/questions/224649/how-to-run-a-command-asking-password-in-background
(last answer on page)

Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450
Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER

More information about the main mailing list