How to speed up Linux

You may have noticed as a Linux user (here we will focus on Ubuntu, but this applies to major distros), that your system has rather been slow or sluggish over time despite the powerful hardware of your computer. Some processes or services take longer times to execute even though the processor is capable of handling a high number of tasks at ease . The reasons however can be diverse but the most common ones are rather few :
– Several open applications can be consuming your RAM
– Many unused or unnecessary applications are eating up resources at boot time
– hardware cannot handle the increasingly demanding load efficiently (specification might be old, .i.e. Hard disk, CPU… )
In this article you will learn how to identify the reasons behind your system’s sluggishness (swap memory area, RAM, CPU,hard disk health status, running services at start-up… ) so that you will be able to solve them and speed up your Linux.

Switch to more efficient desktop alternatives

The GNOME 3 desktop has been introduced to maximize resource efficiency and provide smoother graphics. This will require powerful hardware in order to run properly. Older machines may not compete however with these requirements and might therefore show signs of sluggishness. The good news here is that Ubuntu provides a rather lightweight LX based desktop environment known as Lubuntu . In order to install it, open up your terminal and execute the command below :

sudo apt-get install lubuntu-desktop

Once completed and installed, you will be able to load Lubuntu desktop environment from the login screen.
You can also download an Ubuntu version which has a prebuilt lightweight Lubuntu desktop .

You also have the possibility to use lightweight alternatives to some common applications. For instance you might want to use Gdebi to install packages or AbiWord instead of LibreOffice Writer or AppGrid instead of Ubuntu Software Center …

Services running at boot time

In order to display the list of services that started at boot time, open up your terminal and run the command below:

service –status-all

In case your system is using systemd, which provides a complete solution for system management and startup, you can first get a glimpse into the system boot-up time by running systemd-analyze command without any arguments as follows:

systemd-analyze

This will tell how much time it took the kernel, userspace and initrd to start while booting.

And use systemctl of systemd in order to find the services that run at boot time:

systemctl list-unit-files –state=enabled

Now to view a list of all running services, sorted by initialization time, the blame switch of systemd should be used as follows :

systemd-analyze blame


Use Enter key to view additional services in the list and then ‘q’ to quit.
You will be able to find out which service took unusually longer time during boot and react accordingly. If you want to disable a service from running at boot, you can run the command below :

sudo systemctl disable service_name

In Ubuntu 18.04, you can also use a graphical application in order to prevent a program from launching at startup. This is called ‘Startup Applications’ which you can invoke from the activities menu :

Once the window pops up as shown below :


Click on your chosen app and then press ‘Remove’ in order to prevent the selected program from starting.

To remove or uninstall an application, you may want to read our article :
How to install and uninstall applications on Ubuntu ?

Keep Ubuntu updated

New Ubuntu releases are designed to fix commonly reported bugs as well as improve overall system performance and efficiency. It might be worth understanding Ubuntu release cycle so that you you will be able know to which version/release you can upgrade to.

Every two years in April, Canonical releases a Long Term Support (LTS) enterprise grade release which is the mostly utilized . This represents 95% of all Ubuntu installations worldwide.

Between LTS versions however, Canonical publishes an interim release every six months to allow users to access to newer upstream capabilities for better usability, stability and performance.

Now in order to apply latest Ubuntu updates on your machine, open up your terminal and type in the command below :

sudo apt-get update

And if your release is well behind, you can check for major upgrades availability by running the command :

sudo apt-get upgrade

Press ‘Y’ when prompted. Remember to back up your files before proceeding further with this task.

Replace your hard drive with an SSD

Solid State Drives or SSD, are known to have faster read and write times then when compared to the good old mechanical hard drives. Make sure to buy the right model for your machine though..

Upgrade your RAM

Since Ubuntu 18.04 demands at least 2GB of RAM in order to run smoothly, increasing your RAM might improve your machine overall speed. If you your applications are resource hungry such as videos and games, you might need to add even more RAM to your system.

You can manually install new RAM in your machine. You would just need to make sure to acquire the right model that fits into your computer’s RAM slots.

In order to know how much RAM memory your system has, open up the terminal and run the command below:

free –m

To display your Ubuntu RAM type and other specifications, run the command:

sudo lshw -c memory

For more on this, you might want to read our article : How to Fix High Memory Usage in Linux ?

Use local mirrors

Using a mirror that is very close to your location can help speed up downloading latest software updates. This is because Ubuntu software repositories are scattered or mirrored across many countries. By default, when you set up your system, this is automatically selected, but you can always check that you are using the closest mirror.

To change mirror settings, go to activities and type in ‘Software’ :

Select the one with the caption ‘Software Updates’ as shown above. A new window will pop up :

Next click on the button ‘Settings’ . This will bring yet another dialog box :

Click on the drop down box in front of the text ‘Download from’ and choose the nearest server to your location.
On the other hand, it is possible, when installing applications, to download packages from multiple locations without you intervening directly in the process. This is achieved by the the shell script apt-get wrapper called ‘pt-fast’. This might improve package download and update speed since it will retrieve the packages from multiple connections simultaneously. In order to give this a try, you can install the apt-fast tool via the official PPA by executing the following commands:

sudo add-apt-repository ppa:apt-fast/stable

sudo apt-get update

sudo apt-get install apt-fast

Speed up application load time

Preload is a daemon that runs in the background. Its main purpose is to speed up application load time by monitoring and analyzing software usage behavior. In simple words, it will cache the applications that are used more often in order to improve the overall performance of the system.

In order to install Preload, open up a terminal session and and run the following command:

sudo apt-get install preload

Once this is done, reboot your computer. After the startup, Preload will run in the background. You will hopefully notice an improvement in the frequently used application load time.

Increase Swap space

The ‘Swap’ space can help speed up your system in case your Linux machine does not have enough RAM to handle the daily load.

When you first install Ubuntu, a dedicated swap partition will be assigned on your hard drive. As time goes on, the ‘Swap’ size might need to be increased using ‘Gparted’ which is Ubuntu’s default disk manager.

In your activities section, type in ‘Gparted’ and open it :

You can for instance shrink your main partition after deleting your existing one.

Once this is done, click on ‘Create a new partition’ in order to add a larger swap space. You can always refer to the GParted help manual for assistance. Be careful when resizing your hard drive as it is a sensitive and delicate operation. Backing up your data should be carried out beforehand.

Restart your computer

Over time, the number of open applications, running processes and services, both in the foreground (dialog mode) and in the background can increase during a single session, i.e. since the last boot . This will eventually slow down your system since the available resources like RAM, swap and CPU power are allocated already to these tasks. A simple and obvious solution would be to shutdown your computer once or twice a week. Putting your PC or laptop to sleep won’t help since the processes above will be active again.

Keep your system clean

As time passes, many unnecessary files tend to pile up on you system. This might affect your Ubuntu’s performance especially when your hard drive is not SSD.
Make sure to uninstall the applications that you no longer need and remove unnecessary files (check out the Downloads folder).

In order to empty out the temporary cache that is used by ‘apt-get’. To do this, run the command:

sudo apt-get clean

Unused packages and dependencies can also be removed (safely) using the command below :

sudo apt-get autoremove

For more on this section, you may want to read our article on how to keep your Ubuntu clean ?

Reduce overheating

You may have noticed that when a computer gets hot, it runs slow. This might affect the overall system performance negatively. In order to overcome this issue, two tools can be used to help reduce overheating CPUFREQ and TLP.

The CPUFREQ indicator allows you tweak CPU algorithms which enable the processors to adjust their frequency accordingly depending on the temperature and power consumption of the computer. can be installed by using the following command:

sudo apt-get install indicator-cpufreq

After you restart your computer, you may want to use the Powersave mode:

In order to install TLP, run the following commands in your terminal:

sudo add-apt-repository ppa:linrunner/tlp

sudo apt-get update

sudo apt-get install tlp tlp-rdw

Now to start using TLP, execute the command below :

sudo tlp start

TLP will be running as a background process afterwards.

CPU activity check

As mentioned in the previous section, when the CPU is running hot, it could be that it is handling a lot of intense computations required by some background applications some of which might just be useless.In order to glimpse into the CPU current load, you can use the top the command

The top tool enables you to sort processes according to the highest CPU usage. In order to run the top utility, simply execute the command :

top

The screenshot above provides an overview of the processes which overstrain the CPU. You have the possibility kill the culprits using the kill command.

For more on this, you might want to read our article : How to Fix High Memory Usage in Linux ?

Hard Drive I/O monitoring

In order to monitor your Linux Disk I/O usage, there exists a free top-like utility called iotop which allows the user to monitor the Disk Input/Output activities and prints out a table of the existing I/O utilization by thread or process. In order to install iotop, run the command below:

sudo apt install iotop

After the installation is completed, start iotop by running the command below :

sudo iotop

In the snapshot above, the system is clearly idle system since there are zeros everywhere across the screen. You may notice from time to time few small positive values popping up. This actually data that is being written/read as shown below for the process systemd-journald for example:

You now have the possibility to identify the process that is I/O-hungry so that you can react accordingly.

For more on this, you might want to read our article on Ubuntu monitoring tools.

Conclusion

While there could be many other causes which might lead to slowness or sluggishness of your system, we have tried to provide the most common methods that will help you diagnose your system slow responsiveness and also showed you how to fix them or avoid them altogether by applying some best practices and using simple tools.

4
Leave a Reply

avatar
2 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
adminJayDaniel Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Daniel
Guest
Daniel

I have latest KDE Neon on SSD (no swap, only /) and it is super fast (hence, no real need for tweaking).
But… Do have a penchant for MX19 which is much slower at booting (even with a few things unloaded).
Any suggestions?

Jay
Guest
Jay

Nice article, thank you

Close Menu
Show Buttons
Hide Buttons