Skip to content
Sam's Blog

Technology

How to Save Battery on Any Linux Laptop: Tips, Tools, and Tweaks

10 min read
How to Save Battery on Any Linux Laptop: Tips, Tools, and Tweaks

If you’re a Linux user, you’ve probably experienced the frustration of watching your laptop’s battery drain faster than you’d like. Whether you’re running Ubuntu, Fedora, Arch, or any other distribution, the struggle to maximize battery life is real. While Linux is known for its efficiency and flexibility, it doesn’t always handle power management as gracefully as Windows or macOS. But don’t worry—this guide will walk you through everything you need to know to save battery on any Linux operating system. We’ll cover tools, tweaks, and best practices, all explained in a detailed, humanized way.

Ubuntu is one of the most popular and widely used Linux distributions, and for good reason. Its appeal lies in its reliability, ease of use, and versatility. Many users turn to Ubuntu for programming, development, and other technical tasks, thanks to its robust ecosystem and extensive community support. However, if you’re running Ubuntu—or any Linux distribution—on a laptop, you’ve likely noticed that battery life isn’t its strong suit. While desktop users might not face as many issues, laptop users often struggle with poor battery performance, even on high-end hardware.

For example, you could be using a powerful machine with an NVIDIA GPU and 32 GB of RAM, but when it comes to battery life, Ubuntu might still lag behind. Whether you’re on a MacBook or a gaming laptop, the story is often the same: Linux doesn’t always make the most efficient use of your hardware. This is especially noticeable when performing resource-intensive tasks like deep learning, where every watt of power counts.

To put it into perspective, a well-optimized Windows laptop might last 8–9 hours on a single charge, while a MacBook can stretch beyond 11 hours. On the same hardware, an Ubuntu laptop might only last around 4 hours. This discrepancy isn’t because Linux is inherently inefficient—it’s because Linux distributions aren’t always fine-tuned for the specific hardware they’re running on. When properly configured, Linux can be incredibly power-efficient, but out of the box, it often falls short.

One of the main culprits behind Ubuntu’s battery drain is its default desktop environment, GNOME. While GNOME is sleek and user-friendly, it can be resource-heavy, consuming more power than necessary. Lightweight alternatives like KUbuntu (which uses KDE) or Lubuntu (which uses LXQt) can help mitigate this issue, but even then, the improvements are often modest. The real solution lies in optimizing your system’s power management settings, and that’s where tools like auto-cpufreq and TLP come into play.


The Role of auto-cpufreq in Saving Battery

One of the biggest drains on your laptop’s battery is the CPU. By default, your CPU might be running at higher frequencies than necessary, consuming more power than it needs to. This is where auto-cpufreq shines. It’s a tool designed to optimize your CPU’s performance and power consumption dynamically. Whether your system is idle or under heavy load, auto-cpufreq ensures that your CPU operates efficiently, extending your battery life without sacrificing performance.

Think of auto-cpufreq as a smart assistant for your CPU. It constantly monitors your system’s workload and adjusts the CPU frequency accordingly. When you’re browsing the web or working on a document, it lowers the frequency to save power. When you’re compiling code or running a demanding application, it ramps up the frequency to ensure smooth performance. The result? A laptop that lasts longer on a single charge, without compromising on productivity.


Why Does Linux Drain Battery Faster?

Before diving into solutions, let’s address the root of the problem: Why does Linux seem to drain battery faster than other operating systems?

  1. Hardware Compatibility: Linux kernels are designed to support a wide range of hardware, which can lead to suboptimal power management for specific devices. Unlike macOS, which is tailored for Apple hardware, or Windows, which has extensive vendor support, Linux often relies on generic drivers that may not fully optimize power usage.

  2. Background Processes: Some Linux distributions come with a lot of background services and processes that can consume power unnecessarily. For example, GNOME’s animations and extensions, while visually appealing, can be resource-intensive.

  3. Graphics Drivers: Proprietary graphics drivers (like NVIDIA) can be power-hungry, especially if they’re not properly configured. Integrated GPUs are generally more power-efficient, but switching between GPUs isn’t always seamless on Linux.

  4. Desktop Environments: Heavier desktop environments like GNOME or KDE can consume more power compared to lightweight alternatives like XFCE or LXDE. If you’re using a resource-heavy environment, your battery life will likely suffer.

  5. Lack of Vendor Optimization: Many laptop manufacturers optimize their hardware for Windows or macOS, leaving Linux users to figure out power management on their own.

The good news? Linux is highly customizable, and with the right tools and settings, you can significantly improve your battery life.


Step 1: Optimize Your CPU with auto-cpufreq

The CPU is one of the biggest power consumers in your system. By default, your CPU might be running at higher frequencies than necessary, consuming more power. This is where auto-cpufreq comes in.

What is auto-cpufreq?

auto-cpufreq is a tool designed to automatically optimize your CPU’s performance and power consumption. It adjusts the CPU frequency based on your system’s load, ensuring that your CPU isn’t working harder than it needs to. Think of it as a personal trainer for your CPU—keeping it in shape without overworking it.

Why Use auto-cpufreq?

  • Dynamic Scaling: It dynamically adjusts CPU frequencies based on workload.
  • Battery Saving: It ensures your CPU runs at lower frequencies when idle, saving power.
  • Performance Optimization: It boosts performance when needed, so you don’t sacrifice productivity.

How to Install auto-cpufreq

There are two ways to install auto-cpufreq: via Snap or from the source. I recommend installing it from the source for better control and customization.

Installing from Source

  1. Clone the Repository: Open your terminal and run the following command to clone the auto-cpufreq GitHub repository:

    git clone https://github.com/AdnanHodzic/auto-cpufreq
  2. Navigate to the Directory: Move into the cloned directory:

    cd auto-cpufreq
  3. Run the Installer: Execute the installer script:

    sudo ./auto-cpufreq-installer
  4. Follow the Prompts: The installer will guide you through the process. Type I to proceed with the installation.

  5. Verify Installation: Once installed, you should see a success message. You can now start using auto-cpufreq.

Using auto-cpufreq

auto-cpufreq has three modes:

  1. Monitor Mode: This mode doesn’t make any changes to your system. It simply shows you what auto-cpufreq could do to optimize your CPU.

    sudo auto-cpufreq --monitor
  2. Live Mode: This mode makes temporary changes to your system. It’s useful for testing how your system would perform with auto-cpufreq enabled.

    sudo auto-cpufreq --live
  3. Daemon Mode: This mode makes permanent changes and runs auto-cpufreq as a background service. This is the mode you’ll want to use for long-term battery savings.

    sudo auto-cpufreq --install

    You can check the status of the daemon with:

    sudo systemctl status auto-cpufreq

    To view stats:

    auto-cpufreq --stats

Removing auto-cpufreq

If you ever want to remove auto-cpufreq, simply run:

sudo auto-cpufreq --remove

Step 2: Install and Configure TLP

While auto-cpufreq handles CPU optimization, TLP is another powerful tool that can help you save battery by tweaking various power settings on your system.

What is TLP?

TLP is a feature-rich command-line utility for power management on Linux. It comes with a pre-configured set of power-saving settings that you can customize to suit your needs. TLP is particularly useful for laptops, as it optimizes settings for battery life without requiring manual intervention.

How to Install TLP

Installing TLP is straightforward. On most distributions, you can install it using your package manager.

For Debian/Ubuntu-based systems:

sudo apt install tlp

For Fedora:

sudo dnf install tlp

For Arch Linux:

sudo pacman -S tlp

Starting TLP

After installation, start TLP with:

sudo tlp start

You can check the status of TLP with:

sudo tlp-stat -s

Customizing TLP

TLP comes with a well-commented configuration file located at /etc/tlp.conf. You can edit this file to customize power-saving settings. For example, you can:

  • Enable or disable Wi-Fi power saving.
  • Set the CPU scaling governor.
  • Adjust USB autosuspend settings.

To edit the config file:

sudo nano /etc/tlp.conf

Make your changes, save the file, and restart TLP:

sudo systemctl restart tlp

Removing TLP

If you decide TLP isn’t for you, you can remove it with:

sudo apt purge tlp --auto-remove

Step 3: Additional Tips and Tricks

While auto-cpufreq and TLP are powerful tools, there are other steps you can take to further improve your battery life.

1. Use a Lightweight Desktop Environment

If you’re using a heavy desktop environment like GNOME or KDE, consider switching to a lighter alternative like XFCE or LXDE. These environments consume less power and can significantly extend your battery life.

2. Disable Unnecessary Services

Some services running in the background can consume power unnecessarily. Use systemctl to disable services you don’t need:

sudo systemctl disable <service-name>

3. Optimize Graphics Settings

If you’re using a dedicated GPU, make sure it’s not running when you don’t need it. Tools like nvidia-settings or prime-select can help you switch between integrated and dedicated graphics.

4. Reduce Screen Brightness

Lowering your screen brightness can have a significant impact on battery life. Use your function keys or a tool like xbacklight to adjust brightness.

5. Enable Suspend or Hibernate

When you’re not using your laptop, enable suspend or hibernate to save power. You can configure these options in your system settings.

6. Use Battery-Friendly Applications

Some applications are more power-hungry than others. For example, using a lightweight text editor like vim or nano instead of a full-fledged IDE can save power.


Step 4: Monitor Your Battery Usage

Finally, it’s important to monitor your battery usage to understand where your power is going. Tools like powertop can help you identify power-hungry processes and devices.

Installing powertop

For Debian/Ubuntu-based systems:

sudo apt install powertop

For Fedora:

sudo dnf install powertop

For Arch Linux:

sudo pacman -S powertop

Using powertop

Run powertop in your terminal to see a detailed breakdown of power usage:

sudo powertop

You can also use powertop to automatically optimize your system:

sudo powertop --auto-tune

Conclusion

Saving battery on Linux doesn’t have to be a daunting task. By using tools like auto-cpufreq and TLP, optimizing your system settings, and monitoring your power usage, you can significantly extend your battery life. Remember, Linux is all about customization, so don’t be afraid to experiment with different settings to find what works best for you.

With these tips and tools, you’ll be able to enjoy longer battery life on your Linux laptop, whether you’re coding, browsing, or just relaxing with a movie. Happy power-saving!

Recommended for you

View all posts →