How to Use top and htop for Process Monitoring
Monitoring processes is essential for understanding system performance and health. The top and htop commands are widely used tools in Linux for real-time process monitoring. This tutorial will guide you through how to effectively use both commands.
1. Using the top Command
The top command provides a dynamic view of the system’s processes, including CPU and memory usage. To start top, open your terminal and type:
top
This will display a list of running processes and their resource utilization.
1.1. Understanding the top Output
At the top of the output, you will see system summary information such as:
- Current time and uptime.
- Number of users logged in.
- Load average over the last 1, 5, and 15 minutes.
Below the summary, you will find details about the running processes, including:
- PID: Process ID
- User: The owner of the process
- %CPU: CPU usage percentage
- %MEM: Memory usage percentage
2. Accessing htop
htop is an enhanced version of top with a more user-friendly interface. If htop is not installed, you can install it using:
- For Ubuntu:
sudo apt install htop - For CentOS:
sudo yum install htop
Once installed, you can run htop by typing:
htop
2.1. Understanding the htop Interface
The htop interface displays processes in a visually appealing manner. Key features include:
- Colored bars representing CPU and memory usage.
- Easy navigation through process lists using arrow keys.
- Search and filter functionality.
3. Managing Processes
Both top and htop allow you to manage processes directly:
- To kill a process: In
htop, select the process and pressF9to send a signal. Intop, presskand enter the PID. - To change the priority: In
htop, select a process and pressF7to increase priority orF8to decrease priority.
4. Conclusion
By following this tutorial, you have learned how to use top and htop for monitoring processes in Linux. These tools are essential for system administration, allowing you to keep track of resource usage and manage processes effectively. Continue to explore additional features and options within these tools to enhance your system monitoring capabilities!
