sodcalculator

10 Tech How-To

How to Control CPU Frequency in Ubuntu

Guide 10-48923 · Updated · Step by step

This guide shows you how to take control of your CPU’s clock speed in Ubuntu, whether you want to reduce power consumption, lower fan noise, or squeeze out extra performance. You’ll learn to check current frequencies, switch between CPU governors, and set custom frequency limits using built-in tools and a few command-line utilities.

What You’ll Need

  • A computer running Ubuntu (20.04 or newer recommended)
  • Access to a terminal window (Ctrl+Alt+T)
  • Sudo privileges to change system settings
  • Basic familiarity with the command line

Step-by-Step

  1. Check your current CPU frequency and governor. Open a terminal and run: cat /proc/cpuinfo | grep "cpu MHz" to see each core’s current speed. To see the active governor (the kernel’s frequency scaling policy), run: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor. Typical governors are powersave (lowest speed) and performance (highest speed).
  2. Install the necessary tools. Ubuntu includes the cpufrequtils package to manage frequency scaling. Install it with: sudo apt update && sudo apt install cpufrequtils. This gives you the cpufreq-info and cpufreq-set commands.
  3. View available frequencies and governors. Run cpufreq-info to see the hardware limits of your CPU (minimum and maximum MHz) and the list of available governors. This output tells you what values you can set later.
  4. Switch the governor temporarily. To change the governor for all CPU cores until the next reboot, use: sudo cpufreq-set -g performance (or powersave). This immediately affects performance and power draw. You can verify the change with cpufreq-info.
  5. Set a specific frequency limit. To cap the CPU at a certain frequency (for example, 2.0 GHz), run: sudo cpufreq-set -f 2000MHz. This sets the maximum frequency to 2000 MHz, but the CPU will still scale down when idle. To set a minimum frequency, use -d instead of -f.
  6. Make the governor change permanent. Edit the cpufrequtils configuration file: sudo nano /etc/default/cpufrequtils. Add or change the line to: GOVERNOR="performance" (or your preferred governor). Save and exit. The change takes effect after a reboot.
  7. Use systemd to apply settings at boot (alternative). If the above doesn’t work, create a systemd service. Create a file /etc/systemd/system/cpufreq.service with the following content:
    [Unit]
    Description=Set CPU governor
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/cpufreq-set -g performance
    
    [Install]
    WantedBy=multi-user.target
        

    Then enable it with: sudo systemctl enable cpufreq.service and start it with sudo systemctl start cpufreq.service.

  8. Monitor the results. Use watch -n 1 cpufreq-info to see the current frequency on each core updating every second. You can also use s-tui (install with sudo apt install s-tui) for a graphical real-time view of frequency and temperature.

Common Mistakes

  • Setting a frequency outside the hardware range. The CPU will ignore values below its minimum or above its maximum. Always check cpufreq-info first.
  • Forgetting to use sudo. Changing the governor or frequency requires root privileges. Without sudo, you’ll get a permission error.
  • Confusing the governor with the frequency. The governor is a policy (e.g., “performance” keeps the CPU at max speed), while the frequency is the actual clock speed in MHz. Setting a frequency cap with -f still lets the governor scale below that cap.
  • Assuming the change is permanent. Most command-line changes reset on reboot unless you configure the service or the cpufrequtils file.

Tips

  • For laptops, the powersave governor is usually best to extend battery life. For desktop gaming or heavy workloads, performance reduces latency.
  • You can set different governors per CPU core. For example, to set core 0 to performance: sudo cpufreq-set -c 0 -g performance.
  • Use the ondemand governor if you want a balance: it ramps up speed when needed and drops when idle. It’s often the default.
  • If you’re using a laptop with a hybrid CPU (e.g., Intel P-cores and E-cores), the kernel may handle frequencies differently. Check cpufreq-info to see all cores.

Troubleshooting

  • The cpufreq-set command not found. You haven’t installed cpufrequtils. Run sudo apt install cpufrequtils.
  • “Error: No such file or directory” when accessing /sys files. Your CPU may not expose the cpufreq interface. This can happen on some virtual machines or older hardware. Try loading the acpi-cpufreq module: sudo modprobe acpi-cpufreq.
  • The governor change doesn’t stick after reboot. The /etc/default/cpufrequtils file may not be read by your system. Use the systemd service method described in Step 7 instead.
  • Frequency stays at maximum even with powersave governor. Some BIOS settings (like “Turbo Boost” or “Performance Mode”) override the OS. Check your BIOS/UEFI settings and disable any CPU overclocking or performance modes.
  • You see “cpufreq-set: No CPUFREQ driver available.” This means the kernel doesn’t have a driver for your CPU’s frequency scaling. Try installing linux-generic or check if your CPU is supported (older Intel Atom or AMD K6 processors may not be).

Frequently Asked Questions

What is the difference between a governor and a frequency?

The governor is a policy that decides how the CPU adjusts its frequency. For example, performance keeps the CPU at the highest frequency, while powersave keeps it at the lowest. The frequency is the actual clock speed in MHz.

Can I set a fixed frequency (e.g., 2.5 GHz) and have it stay there?

Yes, but only if you set both the minimum and maximum frequency to the same value. Use sudo cpufreq-set -d 2500MHz -u 2500MHz. Note that this may cause overheating if the CPU can’t dissipate the heat.

Will changing the frequency damage my CPU?

No, as long as you stay within the hardware limits. The CPU has built-in protections to prevent damage from excessive voltage or heat. Setting a lower frequency is safe; setting a higher one beyond the maximum is ignored.

Why does my CPU frequency fluctuate so much?

That’s normal. The CPU scales its frequency based on load, temperature, and power limits. The ondemand or schedutil governors are designed to react quickly to workload changes.

Can I control frequency on a Raspberry Pi running Ubuntu?

Yes, but the available governors are limited (usually powersave and performance). The steps are the same, but you may need to install raspi-config to adjust firmware settings.

Is there a GUI tool to control CPU frequency?

Yes, you can install cpufreq-applet for a panel applet (GNOME), or use s-tui for a terminal-based interface. For a full GUI, cpu-power is available in the Ubuntu Software Center.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →