DEV Community

Cover image for Turbocharge Your Linux: 8 Secrets to Unlock Blazing Speed and Performance! ️‍⚡️‍🔥
Best Codes
Best Codes

Posted on • Edited on

Turbocharge Your Linux: 8 Secrets to Unlock Blazing Speed and Performance! ️‍⚡️‍🔥

Ubuntu Unleashed, Part 2: Improve Speed and Performance on Ubuntu

Welcome back to Ubuntu Unleashed! If you've been following along, you've already started customizing Ubuntu to suit your needs. But let’s be honest — while Ubuntu is a powerful and flexible operating system, it’s not always the fastest out of the box (compared to Debian, Linux Mint, etc.). In this installment, we're going to dig deeper into optimizing your Ubuntu system, ensuring it runs like a finely-tuned sports car. Whether you're a developer, designer, or just an enthusiast, a snappy system can make all the difference.

Note: As @shricodev pointed out to me in the comments, this post isn't limited just to Ubuntu! You can use most of the commands here on any Debian based system, or modify the commands to fit your package environment.

1. Update and Upgrade: The Foundation of Speed

The first and most basic step in optimizing any system is ensuring that all software is up-to-date. Why? Because updates often contain not just security patches, but performance enhancements and bug fixes. An out-of-date system can have unpatched vulnerabilities and performance lags that slow you down.

To update your system, open the terminal and type:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Here’s a breakdown of what this command does:

  • sudo apt update: This command fetches the list of available updates from the repositories configured on your system.
  • sudo apt upgrade -y: This command installs the newest versions of all packages currently installed on your system. The -y flag automatically confirms the installation of these updates.

But don't stop there! After updating, run:

sudo apt full-upgrade -y
Enter fullscreen mode Exit fullscreen mode

This command not only upgrades packages but also handles dependency changes more robustly, ensuring that your system doesn’t have outdated packages hanging around.

2. Unleash the Power of Preload: Predictive Speed Boost

Note: As @shricodev pointed out, you should only use this if you have at least 8 GB RAM.

Preload is a daemon that runs in the background, analyzing your usage patterns and preloading the applications you use most often into memory. This results in quicker load times because the data is already in RAM when you need it.

To install Preload, open your terminal and type:

sudo apt install preload
Enter fullscreen mode Exit fullscreen mode

After installation, Preload will start working immediately without any further configuration required. It’s a subtle but effective way to enhance the responsiveness of your system over time. You may not notice it right away, but over a few days, as Preload learns your habits, you should see a noticeable difference in the time it takes for your favorite apps to start.

3. Trim the Fat: Remove Unnecessary Startup Applications

Every time your system boots, a series of programs start automatically in the background. While some are essential, others might be unnecessary, slowing down your system boot time and consuming valuable resources.

To manage these startup applications, follow these steps:

  1. Open the Startup Applications tool. You can find it in the system menu or by searching for it in your applications menu.
  2. Review the list of applications that are set to start automatically.
  3. Disable anything you don’t need. Be cautious—make sure you’re not disabling something essential to system functionality, like network managers or system update services.

You can also add custom startup applications if you have scripts or apps that you always want running. Just be mindful that the more you add, the slower your startup time will be.

4. Adjust Swappiness: Optimize Memory Usage

Swappiness is a Linux kernel parameter that controls how aggressively the system swaps memory pages from RAM to disk (swap space). A higher swappiness value means the system will use swap space more frequently, which can slow down your system, especially if you have plenty of RAM.

Here’s how you can adjust swappiness:

  1. Check the current swappiness value:
   cat /proc/sys/vm/swappiness
Enter fullscreen mode Exit fullscreen mode

By default, this value is usually set to 60.

  1. Adjust swappiness to a more optimal value (e.g., 10):
   sudo sysctl vm.swappiness=10
Enter fullscreen mode Exit fullscreen mode

This command temporarily sets the swappiness to 10. To make it permanent, you need to edit the /etc/sysctl.conf file:

   sudo nano /etc/sysctl.conf
Enter fullscreen mode Exit fullscreen mode

Add the following line at the end of the file:

   vm.swappiness=10
Enter fullscreen mode Exit fullscreen mode
  1. Why 10?

A swappiness value of 10 tells the system to avoid using swap space until absolutely necessary, relying more on physical RAM. This is beneficial if your system has a decent amount of RAM (4GB or more), as it reduces the need for the slower swap space on your hard drive.

5. Clean Up Your System: Keep it Lean

Over time, your system collects unnecessary files—old packages, cached data, and leftover configuration files from software you’ve removed. Regularly cleaning up these files not only saves disk space but also keeps your system running smoothly.

Use the following commands to clean up:

  1. Remove unnecessary packages:
   sudo apt autoremove
Enter fullscreen mode Exit fullscreen mode

This command removes packages that were installed as dependencies for other software and are no longer needed.

  1. Clean the package cache:
   sudo apt clean
Enter fullscreen mode Exit fullscreen mode

This command clears out the local repository of retrieved package files, freeing up space on your disk.

  1. Remove old kernels:
   sudo apt-get autoremove --purge
Enter fullscreen mode Exit fullscreen mode

Old kernels can take up significant space on your boot partition. This command helps to remove them, ensuring that only the current kernel and one previous version are kept.

You can also install tools like BleachBit for a more thorough cleanup, which can help you get rid of unnecessary files across the entire system.

6. Tweak Your Desktop Environment: Lightweight is Right

The GNOME desktop environment that ships with Ubuntu is beautiful and feature-rich, but it can be a bit heavy on system resources. If you’re looking for a performance boost, consider switching to a lighter desktop environment like XFCE or LXQt. These environments are designed to be fast and efficient, even on older hardware.

If you prefer to stick with GNOME, here are a few tweaks you can make:

  1. Disable unnecessary animations:

Open the GNOME Tweak Tool and navigate to the Appearance section. Under Animations, toggle the setting off. This small change can make the desktop feel more responsive.

  1. Reduce the number of GNOME extensions:

While GNOME extensions are great for customization, having too many can slow down your system. Use the GNOME Extensions app to disable or remove any that you don’t need.

  1. Consider using a different shell theme:

A more minimalist shell theme can reduce the graphical load on your system, making things run smoother.

7. Utilize a Lightweight Window Manager: Minimalism for Maximum Speed

For those who want to push the envelope on performance, consider using a lightweight window manager (WM) instead of a full desktop environment. Window managers like i3, Openbox, or AwesomeWM offer a bare-bones interface with a focus on speed and efficiency. They require a bit more configuration and learning curve but can drastically reduce system overhead.

Why Use a WM?

  • Customization: You have complete control over your environment.
  • Speed: Minimal system resource usage means more power for your applications.
  • Focus: These environments are often distraction-free, which can boost productivity.

Getting Started:

To install i3, for example, you can run:

sudo apt install i3
Enter fullscreen mode Exit fullscreen mode

After installation, you can choose i3 from the login screen. It might feel a bit spartan at first, but once you get the hang of it, you’ll appreciate the speed and efficiency.

8. Boost with ZRAM: Compress Your Memory for More Speed

ZRAM is a kernel feature that creates a compressed block device in RAM. This allows your system to store more data in RAM by compressing it, effectively giving you more usable memory. It’s especially useful on systems with limited RAM (4GB or less).

Installation and Configuration:

  1. Install ZRAM:
   sudo apt install zram-config
Enter fullscreen mode Exit fullscreen mode

After installation, ZRAM will automatically configure itself based on your system’s available RAM. You don’t need to worry about manual configuration unless you want to fine-tune it.

  1. Why Use ZRAM?

ZRAM is particularly effective because it reduces the need to swap to disk, which is much slower than accessing data in RAM. Even on systems with more RAM, it can help improve performance by ensuring that the swap space is used as little as possible.

  1. Monitor ZRAM Usage:

You can monitor your ZRAM usage with the command:

   sudo zramctl
Enter fullscreen mode Exit fullscreen mode

This will give you an overview of how ZRAM is being utilized, including compression ratios and the amount of data stored.

Wrapping Up: Keep Pushing the Limits

Congratulations! You've just supercharged your Ubuntu system, making it faster, more efficient, and better suited to your needs. These tweaks are just the beginning—Ubuntu is incredibly flexible, and there are countless other ways to optimize your setup depending on your specific use case.

Stay tuned for Part 3 of Ubuntu Unleashed, where we’ll explore even more ways to customize and enhance your Ubuntu experience. In the meantime, share your own tips, tricks, or challenges in the comments below.


Happy optimizing! If you’ve got any questions or need help, don’t hesitate to drop a comment. I’m here to help you make the most of your Ubuntu experience.

This article was written by BestCodes with AI assistance. All content has been verified as accurate as of 08/11/2024.

Since @shricodev made some significant contributions to this article, I'd be glad if you'd check out his awesome article too! 🔥

Thanks for reading!

Top comments (20)

Collapse
 
shricodev profile image
Shrijal Acharya

This article should not be limited to Ubuntu. I've done almost everything described here already on my Arch system. The only difference is that you need to change the command for the package manager. 🙂

Note: Only use preload if you have at least 8GB of RAM.

Collapse
 
best_codes profile image
Best Codes

Thanks for the feeback, Shrijal!

I've made a few edits to the post.

Preload does require a lot of RAM. I was not sure if I should include it, since the other tools were focused on things like optimizing RAM usage, but I did. I'll add a note like you suggested.

Collapse
 
shricodev profile image
Shrijal Acharya

Now, that is already much better. Hey, that’s so kind of you to mention my work. Keep growing, buddy! 😇

Thread Thread
 
best_codes profile image
Best Codes

Your work is awesome and deserves to be mentioned!

Thanks for the kind wishes. 🙂

Collapse
 
ddebajyati profile image
Debajyati Dey

Thanks for the insight!

Collapse
 
best_codes profile image
Best Codes

Is this addressing me or Shrijal?

I think Shrijal was quite insightful. 😁

Thread Thread
 
ddebajyati profile image
Debajyati Dey

Hmm... Both are insightful!

Thread Thread
 
best_codes profile image
Best Codes

😃

Collapse
 
alt_exist profile image
Alternate Existance

Cool, i use Manjaro, do you think it will work on my OS?

My device is pretty small, how do i find how much ram it has?

Collapse
 
shricodev profile image
Shrijal Acharya
cat /proc/meminfo | grep -i memtotal | awk '{print $2/1024/1024 " GB"}'
Enter fullscreen mode Exit fullscreen mode

You could use the above command to get the amount of RAM you have in GB. If you want to view it in KB, remove the pipe output to the awk command.

It is distro-independent, so you should be able to use this command in any other distros. If you want to view it in a TUI, you could use something like btop. 👀

Thread Thread
 
alt_exist profile image
Alternate Existance

Wow, thank you!

Collapse
 
best_codes profile image
Best Codes

I've never heard of Manjaro (My knowledge of Linux Distros is rather narrow).

Do you know what package manager it uses?

Thread Thread
 
shricodev profile image
Shrijal Acharya

Manjaro is based on arch, so it should be using the same old pacman. 👾

Thread Thread
 
best_codes profile image
Best Codes

Ah, got it.

Collapse
 
martinbaun profile image
Martin Baun

Great post to bookmark!

Collapse
 
best_codes profile image
Best Codes

Awesome, glad you enjoyed!

Collapse
 
robbenzo24 profile image
Rob Benzo

Nice, I like ZRAM

Collapse
 
best_codes profile image
Best Codes

Thanks Rob! I'm glad the post was useful.

Collapse
 
alt_exist profile image
Alternate Existance

Nice article, can't wait for the next

Collapse
 
best_codes profile image
Best Codes

Thank you!