How can I tell my laptop to shutodwn after finishing running a non-root process

dspyz

I'd like to be able to say:

./run_process.sh; sudo shutdown -P now

but the call to sudo will ask for my password and then my laptop won't shut down because it's waiting for my password. How can I pre-supply the password to sudo when I enter the command (but still run ./run_process.sh from my user account without sudo)?

icyrock.com

You can do some "reverse psychology" here:

sudo bash -c "sudo -u dspyz ./run_process.sh; shutdown -P now"

i.e. run sudo, then "unsudo" to your process as your self (where dspyz is your user name on that system), not as root, and then shutdown under the original sudo.

You can try this to see what it will do:

sudo bash -c 'sudo -u dspyz id; echo `id`'

where id command shows the current user's ID and will be your (i.e. dspyz's ID for the first id, which plays the role of ./run_process.sh, but will be root for the second id, which plays the role of shutdown -P now).

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I tell if a hard drive will fit my laptop?

From Dev

How do I tell if my laptop fans can be controlled by Ubuntu

From Dev

How can I fix the boot process on my HP laptop?

From Dev

How can I tell if Elastic Beanstalk is running my config files?

From Dev

How can I tell if my batch file is running?

From Dev

How can I tell if Elastic Beanstalk is running my config files?

From Dev

How can I tell if the wireless network card in my laptop supports 802.11n?

From Dev

How can I tell which SATA Revision my Laptop Motherboard Supports?

From Dev

How can I tell if my Windows 10 laptop has an encrypted drive or not?

From Dev

How do I tell whether my laptop battery is good?

From Dev

How can I tell if cntlm is running?

From Dev

Can a laptop tell if a charger is non-OEM?

From Dev

How can I turn my laptop display off completely (while script is running)?

From Dev

How can I mute my laptop for an hour

From Dev

How can I check RAM of my laptop?

From Dev

How can I use my laptop keyboard as other laptop keyboard?

From Dev

How can I tell if my perl process has used the regex $PREMATCH/$MATCH/$POSTMATCH vars (or the short equivilents $`/$'/$&)?

From Dev

How can I tell if my Android app is running in Google Cloud Test Lab?

From Dev

How can I tell if my Cordova application is running on a simulator or real device?

From Dev

How can I tell if my interface{} is a pointer?

From Dev

How can I have an animation before I finishing my activity?

From Dev

Can I tell if my Chrome Extension is running on Windows?

From Dev

Running `VBoxManage startvm ...`: how can I tell when the VM is running?

From Dev

Can I continue playing music after suspending my laptop?

From Dev

How do I tell if my container is running inside a Kubernetes cluster?

From Dev

How can I tell if I am running in android:isolatedProcess?

From Dev

How can I tell which user limit I am running into?

From Dev

How can I tell what version of apache I'm running?

From Dev

How can I tell which version of Varnish I'm running?

Related Related

  1. 1

    How can I tell if a hard drive will fit my laptop?

  2. 2

    How do I tell if my laptop fans can be controlled by Ubuntu

  3. 3

    How can I fix the boot process on my HP laptop?

  4. 4

    How can I tell if Elastic Beanstalk is running my config files?

  5. 5

    How can I tell if my batch file is running?

  6. 6

    How can I tell if Elastic Beanstalk is running my config files?

  7. 7

    How can I tell if the wireless network card in my laptop supports 802.11n?

  8. 8

    How can I tell which SATA Revision my Laptop Motherboard Supports?

  9. 9

    How can I tell if my Windows 10 laptop has an encrypted drive or not?

  10. 10

    How do I tell whether my laptop battery is good?

  11. 11

    How can I tell if cntlm is running?

  12. 12

    Can a laptop tell if a charger is non-OEM?

  13. 13

    How can I turn my laptop display off completely (while script is running)?

  14. 14

    How can I mute my laptop for an hour

  15. 15

    How can I check RAM of my laptop?

  16. 16

    How can I use my laptop keyboard as other laptop keyboard?

  17. 17

    How can I tell if my perl process has used the regex $PREMATCH/$MATCH/$POSTMATCH vars (or the short equivilents $`/$'/$&)?

  18. 18

    How can I tell if my Android app is running in Google Cloud Test Lab?

  19. 19

    How can I tell if my Cordova application is running on a simulator or real device?

  20. 20

    How can I tell if my interface{} is a pointer?

  21. 21

    How can I have an animation before I finishing my activity?

  22. 22

    Can I tell if my Chrome Extension is running on Windows?

  23. 23

    Running `VBoxManage startvm ...`: how can I tell when the VM is running?

  24. 24

    Can I continue playing music after suspending my laptop?

  25. 25

    How do I tell if my container is running inside a Kubernetes cluster?

  26. 26

    How can I tell if I am running in android:isolatedProcess?

  27. 27

    How can I tell which user limit I am running into?

  28. 28

    How can I tell what version of apache I'm running?

  29. 29

    How can I tell which version of Varnish I'm running?

HotTag

Archive