Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to force powertop to run when I log in by using the Startup Applications wizard in Ubuntu. Under the 'Command' entry, I've placed gnome-terminal -x /home/***/Documents/programming/scripts/powertop.sh. It's using a one-line bash shell script:

echo "******" | sudo -S powertop

This inputs my superuser password correctly but doesn't allow me to interact with powertop after it's initialized because it's continuously running echo.

How can I get privileges to run powertop using a shell script, yet still be able to use it in gnome-terminal?

share|improve this question
up vote 5 down vote accepted

Assuming your powertop is in /usr/sbin, you can use sudo /usr/sbin/powertop with no password. To do this you need to run visudo and append the followind line, substituting yourusername with the real one:

yourusername ALL=(root) NOPASSWD: /usr/sbin/powertop
share|improve this answer
This works! (And thankfully, I can avoid the security issue of storing my password in a shell script...) – sionydus Dec 31 '11 at 8:45
@user15008 If this is the right answer can you accept it? – Michael Mrozek Dec 31 '11 at 9:20
Sorry, I had forgotten – sionydus Dec 31 '11 at 19:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.