Checking The Health Of Your Computer Thru The LINUX CLI - Post #32
Hello baby pup OREO, sleep well and grow fast. May you bring forth joy and happiness to my humble family……...
IS MY COMPUTER HAVING PROBLEMS?
Oftentimes we are faced with a situation wherein the computer we are using just seems to stall and somewhat laggy. Words as you type seems slow in appearing, mouse moved over to a certain spot on the monitor does not produce the expected effect, and the most annoying of all, mouse cursor moving but nothing else follows, not even a keyboard press of any letter.
There are many reasons why a computer stalls, and if it is hardware related I really have to declare in advance that there is nothing you can do about it except buy a new one to replace the damaged component (memory, disk, cpu, power supply etc). But then again, and this will be about 90 percent of the time, the stuttering mouse is caused by a wayward program that just used much CPU or memory resources. What better way to solve this than to find and kill the said culprit, I mean the program culprit.
If only you are on a linux desktop (I have Linux Mint 18.1), you can really do something about this annoying state. And this is what I will lay down here.
ENTER THE LINUX CLI MONITORING COMMANDS
I will go directly to the most annoying, mouse moving, nothing happens on the keyboard. If this happens, just a word of caution: “DO NOT FORCE SHUTOFF YOUR COMPUTER”. Oftentimes, this is caused by a wayward program just writing many things on the disk thereby eating up lots of CPU or memory resource. This is just invented by man remember? And oftentimes, what man have invented will always exhibit problems because no man is perfect. Good thing that man have also made tools to solve his own generated problem.
Press this simultaneously on your keyboard to go to an all-black, pure cli screen with just the login prompt: “Ctrl+Alt+F1”. In my Linux Mint 18.1 desktop, this action will bring me to a pure linux cli screen, and it is at this screen that I am KING! You may ask why a king? Well, for one, a king can always do what he wants right? So yeah, for sure, this all-powerful pure cli will let you do all what you want with your suddenly-becoming-a-zombie desktop. By the way, do not forget to login as the root user on the said pure linux cli screen to be able for you to do all commands necessary to solve the issue.
This is what a pure linux cli will look like:
LET US FIND THE SON-OF-A-TWEETYBIRD APP THAT CAUSED THIS
I will list the tools one by one and this will also make it a good step-by-step procedure:
-1. The HTOP command
First off is htop, and if it is not installed yet you can type this at the pure cli screen: “apt-get install htop” for you to be able to use its wonderful features. Actually htop is a color-coded monitoring tool for linux that is available on almost all linux distributions. It will give us a very good representation, not graphically but text-fully, making it a perfect tool for our situationer here of a zombie desktop.
At the upper left are numbers (these are the CPUs), the Mem (this is the memory use) and the Swp (the swap). Here are valuable hints:
-If the Swp have bars to indicate usage, this means that memory use is critical
-If all the CPUs numbered on the upper left (“1 to 4” or “1 to 2” depends on your computer specs) have bars indicating it is more than half of the black space, this means there is a program that is hanging tight and causing havoc.
-On the left side of the screen are numbers, these numbers are PIDs (process IDs) and will be our main road to salvation. Almost always, the program that causes the computer to stall is the first on this list, so all we have to do is find the corresponding PID number to its left and note it down.
Once you have the PID number noted, go out of the htop screen by typing on the keyboard: “Ctrl+C”, this will bring you again to the pure linux cli to be able to issue this command:
“killall -9 PID”
The PID as per the command is the noted PID number earlier. If that does not solve the zombie issue, go back again to the htop screen and note the PID of the program that is first on the list, meaning at the top-most.
-2. The DF command
The df command will tell us how much usage do we have currently as far as disks are concerned. And since we all know that the hardisk is where our files and programs are located, it is just proper that we check its usage from time to time, or even at the point of the desktop zombie apocalypse. Issue this command on the pure linux cli:
“df -h”
The most important thing to note for the command “df -h” is the column labeled “Use%” as this indicates how full is the disk or the folder that it corresponds to. Seeing a 100% in this column surely tells us that the disk is full and is the most likely cause of the zombie desktop behaviors. Just clean up your files if this is the case, particularly at the folder that corresponds the indicated 100% usage, the folder name being on the left most.
-3. The PS commands
When all hell breaks loose, there is a command that does not fail me, and I am now sharing it to you. Issue this command at the pure linux cli:
“ps aux | sort -nrk 3,3 | head -n1”
This may be the last line of your desktop’s defense, but I assure you this will solve the zombie issue that will at least give you the chance to reboot your machine smoothly for a full recovery. On the left of this command once issued is the username, and immediately to the right of the username is the PID of the program that is most probably the culprit. Issue these commands in order at the pure linux cli to recover:
-”kill -9 PID”
-”reboot”
Just remember to wait for the kill command to finish its task before you reboot as I am just thinking of the worst case scenario where the desktop is really in zombie mode.
I am confident that no zombie desktop apocalypse can purely take over your productivity with these three very important forensic commands using the pure linux cli. I bet you will be as successful an investigator like this man below using the mentioned tools:
Just one last disclaimer, “provided your hardware is still intact” when the zombie attacked!