We all detest when a running Linux system becomes slow or sluggish over time. You might have invested in powerful PC hardware but find it getting slow when you run multiple applications. Linux systems are known for their resilience and speed of processes. However, sometimes processes or services take longer to execute than expected.
The reasons can range from system applications consuming your RAM, many unnecessary applications consuming system resources, poorly configured systems, or inefficient hardware resources that cannot handle increasing demand.
Linux system provides several tools, tweaks, and techniques of self-healing to improve system performance. My first tweak is to keep my system lean where I install only the software I need. It makes a big difference in how many processors and memory my system uses. Next, the article will highlight a simplified approach to solve system sluggishness like managing start-up services, hardware improvements, managing multiple tasks, and tips to make your browser efficient. The examples in the article will focus on Fedora and Ubuntu systems but should also apply to all major Linux distros.
Tools to monitor and improve Linux system performance
The best approach to solve any system problem is to monitor it before you make any configurations. After you identify the source of a problem, you make an update, then inspect the system a second time to verify if the changes made brought the desired changes.
The Linux community provide several command line and graphical open-source tools to monitor system performance. Tools like GNOME System Monitor, Conky, Grafana, KDE System Guard, GKrellM, and terminal commands like top or iotop can help you sort processes according to CPU usage. Whichever tool you pick, ensure you check processor usage, memory use, or even monitor other hardware resources, such as storage disks and USB storage, networking tools, or even graphics processors.
Choose an efficient Desktop
The new Fedora 34 distro features GNOME 40 with a few new features and tweaks that make it reliable and consistent. Sometimes, the default desktop environment from your distro might not be responsive enough, and you might be required to install a lighter desktop. I stick with GNOME 40 and favor tweaks over a new installation, but you can try out desktop environments like Xfce, LXDE, or LXQT that require fewer resources to function optimally.
Install XFCE, LXDE, Cinnamon, or LXQT desktop environment on Fedora Linux with the following steps.
Check available desktop environments with the following command:
$ sudo dnf grouplist -v
Choose and install your favorite desktop environment.
$ sudo dnf install [desktop_environment]
Example to install XFCE desktop
$ sudo dnf install @xfce-desktop
The command will install a desktop environment minus the common packages that would have been installed when you first installed Fedora.
You can also increase the responsiveness of your desktop environment with the following file manager tweaks:
- Try to disable visual effects like composting, animation, and thumbnail images.
- Use lightweight file managers such as XFE or Thunar that handle essential file manager features efficiently.
- Learn to use keyboard shortcuts.
- Configure your desktop to use a lightweight window manager.
- You can go the extra mile by switching from a desktop for window managers such as Fluxbox, JWM, and Openbox. A window manager will run faster than a desktop but is also less user-friendly and might not have icons or a system dock.
Linux system update & cleanup
Keeping your system updated improves its overall performance and efficiency. Each Linux distro release comes with common bug fixes, patches, updates, upgrades, and newer upstream opensource tools. For example, Fedora has a release cycle of six months, while Canonical releases a Long Term Support (LTS) enterprise-grade Ubuntu release every two years in April.
To perform a full system update and upgrade, grab some coffee and run the following commands.
#Fedora $ sudo dnf upgrade --refresh $ sudo dnf autoremove $ sudo dnf update $ sudo reboot
#Ubuntu $ sudo apt-get update $ sudo apt-get upgrade
Another key to improved system performance is keeping your system lean, clean, and rid of any unnecessary files or caches in your system. Make sure to uninstall the applications that you no longer need and remove unnecessary downloaded files.
Run the following command to remove temporary caches in your system:
$ sudo apt-get clean #Ubuntu
Remove unused packages and dependencies using the following command:
$ sudo apt-get autoremove #Ubuntu $ sudo dnf autoremove #Fedora
Enable the fastest mirror & local mirrors
Enabling the fastest mirror in Fedora or local mirrors in Ubuntu can help you speed up your system when downloading the latest software updates. The Fastest mirror is a plugin that determines the nearest geographical mirror available to you for faster downloads.
To enable the fastest mirror in Fedora 34, add the following flags to the DNF configuration file [/etc/dnf/dnf.conf].
echo 'fastestmirror=true' | sudo tee -a /etc/dnf/dnf.conf echo 'max_parallel_downloads=7' | sudo tee -a /etc/dnf/dnf.conf echo 'deltarpm=true' | sudo tee -a /etc/dnf/dnf.conf cat /etc/dnf/dnf.conf # [main] # gpgcheck=1 # installonly_limit=5 # clean_requirements_on_remove=True # skip_if_unavailable=True # fastestmirror=1 # max_parallel_downloads=7
In Ubuntu, you can enable local mirrors for software downloads through software settings, or you can use the apt-fast tool to download packages from multiple locations effectively. Apt-fast will retrieve and download packages from multiple connections simultaneously. You can install the apt-fast tool via the official PPA with the following commands:
$ sudo add-apt-repository ppa:apt-fast/stable $ sudo apt-get update $ sudo apt-get install apt-fast
Manage system start-up processes
A majority of Linux distros provide the systemd suite to manage and optimize system start-up services and resources. You can use the systemd software suite to get your system up and running, optimize processes, debug, troubleshoot system services, and improve overall performance.
Please run the following systemd command to analyze system boot-up time and the time it took the kernel, userspace, and initrd to start while booting.
List all services that run at boot time:
$ systemctl list-unit-files –state=enabled
List all running services sorted by initialization time with the systemd-analyze blame command:
$ systemd-analyze blame
The command will analyze the processes and services that took unusually a long time to start during boot. If necessary, disable a service from running at boot with the following command:
$ sudo systemctl disable foo_service
Other systemd optimizations
Systemd offers fast boot times, but you can optimize it further with the following steps:
- Consider disabling SELinux by adding selinux=0 on the kernel command-line. Note that experienced sysadmins recommend leaving SElinux on for security reasons.
- Bypass the initrd if you use one in your Linux system.
- Use Journal, the default logging tool in systemd, and consider uninstalling Syslog.
- Consider removing cron and use systemd timers instead.
- Use a modern desktop environment like GNOME 40.
- Check and disable any unnecessary boot processes or services.
- Please get rid of shell-based services like SysV init scripts and replace them with unit files.
Read on: How to manage systemd services at start-up.
Install preload to speed up application load time
Preload is a daemon to gather and analyze information about processes and services running on the system. It speeds up service load time by caching frequently used apps which improves the overall performance.
Run the following command to install Preload:
$ sudo apt-get install preload #Ubuntu $ sudo dnf install preload #Fedora
Reboot your system to run Preload in the background and notice improvement load times of your frequently used application.
Apply the following principles when running resource-intensive applications like gaming, video editors, and virtual machine hosts.
- Run only one resource hog app at a time.
- Do not run a resource-intensive app in the background.
- Limit the number of apps you use at one time, and close any you aren’t using.
- Limit concurrency to improve performance for any running apps.
- Background processing presents a similar opportunity.
- Schedule resource-intensive background processes like software updates, filesystem verification, backups, image copies, and large downloads for off-hours. GUI tools like KCron or Zeit make it easy to manage and schedule tasks.
Browser tips and tweaks
A browser is one of the apps we all run daily. Browser increases our productivity from accessing emails, search engines, social media websites, or even testing web applications for developers. A good choice of a browser and simple tweaks will get your system functioning at an optimum. I favor Firefox because it provides advanced web development tools, is fast, fully open source, and is the default browser for Fedora.
Here are some tweaks and tips to get the best out of your system’s resources and browser.
- Website ads and trackers consume most of the CPU your PC spends on-page processing. Therefore, you should block ads with a browser extension and also block trackers. Try tools like Privacy Badger, uBlock Origin.
- Disable autoplay for videos and animation with Disable HTML5 Autoplay extension in Firefox or Yet Another Autoplay Blocker extension in Chromium or Chrome.
- Remove all unnecessary add-ons and extensions from your browser.
- For powerful PCs, try multiprocess and multithread open source browsers like Firefox or Chromium.
- Use a lightweight browser like Dillo if your PC has limited resources.
- Run a single instance of a browser at a time to reduce resource consumption.
- Open only a few tabs at a time and close tabs when done using.
- Uninstall and reinstall your browser to get the latest browser update and rid it of corrupted data caches and unnecessary extensions.
Invest in hardware upgrades
Replace HDD with SSD
Solid State Drives [SSD] are known to have faster read and write times when compared to hard disk drives [HDD]. These two drives function the same but data in SSD is stored on interconnected flash memory chips that retain the data even when there’s no power flowing. In essence, SSD provides faster boots, fast file transfers, and launches and runs applications faster. Whether you use your PC for gaming, school assignment/projects, development, or business, the extra speed may be the difference between getting your code to production or delivering your presentation on time. However, note that SSDs are more expensive than HDD drives.
Upgrade your RAM
Linux distros like Fedora 34 or Ubuntu 18.04 require at least 2GB of RAM to install and run successfully. You should increase system RAM if you run resource-intensive software for gaming, videos, or graphics software. You can acquire the ideal model that fits into your computer’s RAM slots and manually install it on your PC.
Run the following commands to know how much RAM your system is using:
$ free –m
You can also use the # top or # htop to get more information on RAM usage.
# top # htop
Increase Swap space
The ‘Swap’ space can help improve system performance if your computer does not have enough RAM to process. When you first install a distro, ensure you dedicate swap partition space that is approximately the size of your RAM. For example, if your system has 4GB of RAM, configure a Swap partition of 4GB. You can also increase your Swap size using the Gparted disk manager available in both Fedora and Ubuntu.
Reducing overheating of the system
An overheating computer always runs slow and might negatively affect the overall system performance. You can use the TLP and cpufreq to help you reduce and manage overheating in your system. cpufreq allows users to tweak CPU algorithms and enable system processors to adjust their frequency depending on computer temperature and power consumption.
Install CPUFREO using the following command:
$ sudo apt-get install indicator-cpufreq
TLP is a power management utility that can help you optimize your Laptop’s battery and view your power consumption reports. But, first, you need to install TLP and let it work in the background.
Run the following commands install TLP:
Ubuntu sudo add-apt-repository ppa:linrunner/tlp sudo apt-get update sudo apt-get install tlp tlp-rdw
Fedora $ sudo dnf install tlp tlp-rdw
Execute the command below to start using TLP:
sudo tlp start
The command will launch TLP and let it run as a background process.
Then, run the following command to view the battery information and status.
$ sudo tlp-stat -b
The article highlights some common causes of system sluggishness, tools, and methods to help you diagnose your system. We also show how to fix problems or avoid them altogether by applying some best practices and simple systemd, PC, and browser tweaks. And just in case you have limited hardware resources, you can spare some extra cash and invest in additional RAM and SSD hardware.
Please share any performance tips you use for your system!