I would like to execute a command which requires sudo privileges. Specifically, I want to set my CPU frequency to a performance governor using the following script.

sudo cpufreq-set -g performance

What I have done so far is I have added this custom command from System Settings -> Applications -> Startup. I also changed the permission of the newly created file from ~/.config/autostart. However, the sudo command is still not executing. Are there any other ways to do this?


If you have a laptop, you can use TLP to automatically set it.

If you prefer a more simple method, you can create a systemd service that will execute at startup.

sudo io.elementary.code /etc/systemd/system/cpuperformance.service

Description=Set CPU performance governor

ExecStart=/usr/bin/cpufreq-set -g performance


Close that file and then execute sudo systemctl daemon-reload && sudo systemctl enable cpuperformance.service.

If you want to disable this in the future you can use sudo systemctl disable cpuperformance.service and sudo rm /etc/systemd/system/cpuperformance.service to remove the file.

  • So laptop power management tools are not installed by default in elementary OS? Is TLP the only way to do this kind of high-performance configuration? I looked into Debian and it seems that TLP is also not included by default in their laptop-related packages installed via tasksel laptop command. Sep 20 '20 at 15:24
  • No, TLP is not installed by default. And the method I described works on laptops as well however I prefer to use TLP since it allows for many more configurations that you'll probably want to change anyway if you're getting into this sort of thing.
    – Maccer
    Sep 20 '20 at 16:04
  • The thing is, I don't really like installing packages which could have the possibility of conflicting. I already have cpufrequtils installed and actually, it is Debian's recommended way of configuring the CPU governor to use. If I just want to maximize the CPU frequency regardless whether I am on battery or AC power, do I really need to have the tlp package included? Sep 20 '20 at 22:24
  • As I said, you don't need to install tlp. Using a systemd service will work just fine.
    – Maccer
    Sep 21 '20 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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