1

I want to create a keybinding Ctrl+Alt+Delete on my Ubuntu PC. It should open htop, but I want maximum priority for it. I use this command.

xterm -fullscreen -fa 'Monospace' -fs 13 -e htop

It works well, but when I add priority, it needs root permissions

$ nice -n -20 xterm -fullscreen -fa 'Monospace' -fs 13 -e htop
nice: cannot set niceness: Permission denied

When I use sudo, it works, but it runs the whole command as root. How can I run only nice with sudo? It would be ideal if it didn't ask for a password.

Zanna
  • 72,312
FK-VH
  • 188

1 Answers1

1

You can use nice on existing PID's with renice

So start the terminal as usual

$ sudo renice -n -20 -p HTOP_PID

If you are using different shells/windows for this, you can find the pid ps -A | grep htop there are numerous ways to extract PID from the output programmatically which would allow scripts to handle this.

Otherwise you could, as suggested in a comment, execute

sudo nice -n -20 su USER htop instead of straight htop

crasic
  • 3,882