In this write-up, we will discover the usage of htop and ping commands to troubleshoot the Raspberry Pi processes and networking problems.
What is a htop command in the Raspberry Pi operating system
The htop is a command-line utility that is used to monitor the different processes running on the system. It will tell you about the performance of the CPU along with the processes which are using the RAM and about the cache memory. It will also demonstrate the average load and number of total tasks running on the system, and all this information will be displayed in real-time.
How to use the htop command to troubleshoot the Raspberry Pi
We can troubleshoot the performance of the CPU and the memory by using the htop command:
A screen with the different statistics will be displayed:
The above statistics are divided into different sections which are explained as
CPU: The CPU will be displaying different lines depending on the number of cores which a computer have for example, in our case the CPU is a four-core so it displayed the four lines and next to it is showing the load on the CPU in terms of %, in our case it is showing approximately to 3.9% which means the system has no load, if it shows 100 % then the system is fully loaded.
The vertical line color will indicate the process of the CPU like the green color represents the normal processes, the red color represents the Kernel processes, and the blue color represents the low priority processes:
Mem: This is showing the memory usage for example in our case the 223 MB memory is in use out of the 3.75 GB memory and the lines of different colors are displaying the amount of memory used for which purpose, like green color represents the used memory pages, the blue line representing the buffer pages, and the orange color line representing the cache pages.
In the above output, we can also see the average load and the uptime of the Raspberry Pi.
The detail of other processes with their PIDs and the memory consumed by them is displayed:
We can kill the processes by using the PID of the process with the htop command, for example, we want to kill PID 13946 (VLC PID), we will use the command:
What is a ping command in the Raspberry Pi operating system
The ping command is an important command-line utility that deals with the troubleshooting and testing of the network connections in the Raspberry Pi. This command is used to detect if the network device is in the range of our Raspberry Pi operating system or not. The ping command sends the requests to the concerned network device and receives the message in order to a successful response. This response will display different statistics like how much time it took to connect the network, how many bytes were received, and what the TTL (time to live) is.
How to use the ping command to troubleshoot the Raspberry Pi
The ping command is used to troubleshoot the network problems of the Raspberry Pi: it is used to check the connectivity of your device with the internet, it also checks the availability of the remotely connected device, moreover finds out the issues like dropped packets.
The basic syntax of the ping command is:
We can use different options with the ping command (this is optional), and then we will type the hostname or the IP address of the concerned machine. To understand this, we will ping the localhost to display the details about the network connection:
It starts sending the packages, we will use the “CTRL+C” to stop the process and will observe the results:
To test the performance of the network under the heavy loads, we will use the “-f” option, which will send a large number of packets in a small time interval and visualize the performance of the network under heavy load:
To get more information about the usage of the ping command, we can see its manual by using the command:
The manual will be open where its all options and their usage are displayed:
Conclusion
Both the command-line utilities of the htop and ping is used for different purposes: the htop command-line utility is used to monitor the processes of the system and load on the CPU. Similarly, the ping command is used to monitor and resolve the issues related to the networking. In this write-up, we have discussed the htop and the ping commands to troubleshoot the CPU processes and networking issues.