How To Troubleshoot Performance Issue In Linux


Linux is well known for its performance, But what if you mess up with its configuration. In this post we will see some ways to resolve the slowness issue in Linux system.

Below are some common reasons of slowness in any system.

-So many unnecessary background services are running

-A buggy application consuming/eating RAM.

-A hidden background service which is working continuously.

-RAM consumed by buffer/cache

-Root (/) , /home partitions are almost full.

-Unsupported drivers & any misconfigurations.

To deal with these common issue , we will use some important Linux commands which will help us to resolve our issue. Lets see..

Hardware Details Commands: This could be helpful to find where your hardware have some issue that cause for system slowness.
i) sudo inxi --full --verbosity=7 --filter --no-host

This command will gives you the complete details about the system hardware configuration including BIOS & current OS. 

Note: Using only --full option, will include the mac address and home directories also. this makes the privacy issue. So please use --filter to filter out these options when send these information to any third-party vendor.

ii) sudo inxi -SMGxxxz

This command is same as above using options put some variations in output. Check man pages about more info.

iii) dmidecode

This is another useful common which provide the huge details of every piece of system hardware component in the form of table.

iv) lscpu; lsmem; lstopo

These are also helpful to see the complete details of cpu , memory, system memory topology.

v) Run the memtest in your system to check the memory issues & faults. You can run the memtest from by making it bootable into USB & boot from it.

Cleaning Cache : This is another option while deal with slowness issue. sometimes everything is fine & you just ignore the root and home partition space . that was filled up by the cache data. Its better to clean cache data time to time. You can do it will cron job also. But here we will see how to clear cache files manually.

i)  df -h   ;   lsblk ; du -h /path  

These command will help you to show used and free spaces in your system. If you found the space is not enough try to clean garbage data from your system

ii) rm -rf ./cache/*

If you find some load on your home partition size , you can clear the local cache files which are hidden in your home files.

iii) yum clean all or  rm -rf /var/cache/yum  [for rmp base distro]

pacman -Sc [for arch base distro]

sudo apt-get autoclean   [for deb base distro]

sudo apt-get autoremove  [for deb base distro]

You can clear the cache of relative distro's packages cache local repositories. This will improve the performance.How ever you only need to clear the local repository cache when you feel that its take too much space.

You can use the Bleachbit tool in order to clean the cache in the Linux system

iii)   echo 1 > /proc/sys/vm/drop_caches   #  To free pagecache:

    echo 2 > /proc/sys/vm/drop_caches # To free entries and inodes:

    echo 3 > /proc/sys/vm/drop_caches  # To free pagecache, entries and inodes:
These commands will remove the loads from the RAM buffer memory. Its useful when you are running out of memory due to page cache loaded in main memory buffer portion. 

Note: Run these command with root privileges.

Logs : Checking logs will very helpful while troubleshooting with slowness issue. Its tells lots about the system behavior. The default location for logs files are /var/log/ . You will find logs related to system & application here.

i) journalctl 

This utility can concatenate all the logs in one place. Just run this command without any option all logs will shown to you.

ii) journalctl -b -0 -p3 

Where -b stands for boot , with no value(-b -0) "last boot" , with value 1(-b -1) "boot before last boot", with value 2 (-b -2) "third last boot " so on. And a postive number (-b 1) will show logs of very first boot.

Where -p stands for priority "emerg" (0), "alert" (1), "crit" (2), "err" (3), "warning" (4), "notice" (5), "info" (6), "debug" (7)

iii) dmesg

This command will show the logs of kernel ring buffer , the logs of operations executed by kernel itself. Find suspecious operations if they slow down the system.

iv) dmesg -h -k
This will show the kernel messages with human readable format.
Running Processes : You can also check the running background process which may be cause of slow down the system. Find them and google about their functionalities and if necessary kill them.

Some commands to check the processes are below.

i) ps ; ps -aux ; ps -ax

These command will show the currently running process under the current user.

ii) top ; htop

These commands could be helpful while checking the current loads taken by applications on hardware resources like CPU , RAM ,SWAP paritions.

iii) systemd-analyze blame

This is another useful command while troubleshooting slowness issue . It will show the start time taken by all services while system boot up.

If you would like to add some more steps or commands to find out the slowness issue in Linux system, Please comment below. I will surely add those steps in this post.

Sharing is Caring. If you find the post and information useful , Please comment below & share post with your friends.😀

Post a Comment