Skip to main content

How to speed up Ubuntu 18.04 by cleaning out old files?


In this blog i'll show you how to speed up Ubuntu 18.04 by cleaning out old files and updates. The Ubuntu operating system is based on the Linux kernel. Both are free and open source software, meaning that the code used is available online for others to use and review. 

Over time however, your Ubuntu 18.04 installation can become more sluggish. This can be due to small amounts of free disk space or possible low virtual memory due to the number of programs you’ve downloaded.

In this blog you will learn how to speed up Ubuntu 18.04 by clearing out outdated files and caches. Some other obvious steps include installing more RAM, replacing HDD with SDD as well as more obscure ones like resizing your machine's swap space.

Coming to the point, I've made a bash script which will update and clean your system by removing outdated files and caches.

Step 1 : Copy the following code in your test editor and save with the extension .sh (i.e updateAndClean.sh).

 #!/bin/bash  
 sudo apt update  
 sudo apt upgrade  
 sudo apt-get clean  
 sudo apt-get autoclean  
 sudo apt-get autoremove --purge  
 sudo apt-get autoremove  
 dpkg -l | grep '^rc' | awk '{print $2}' > config_list.txt  
 if [ -s config_list.txt ]  
 then  
 sudo xargs dpkg --purge < config_list.txt  
 fi  
 if [ -f /var/run/reboot-required ]; then  
 echo '**** reboot required ****'  
 fi  
   


Step 2 :Change the permissions of the file to make it executable.

  1. Open the terminal.(ctrl + alt + t)
  2. go to the file updateAndClean.sh directory.
  3. write the following command in the terminal.
  4.  chmod u+x updateAndClean.sh            

Step 3 : Execute the script.

    1. Execute the script from the current directory using ./updateAndClean.sh command.
    Now that's it. If it really speed up your system do let me know in the comment. :)

    Comments