Monitoring your system performance through the Terminal is fast, lightweight, and powerful. Follow these step-by-step instructions to use top and htop effectively.
πΉ Method 1: Using top (Built-in Tool)
π₯οΈ Step 1: Open Terminal
β’ macOS: Open Terminal from Applications β Utilities
β’ Linux: Press Ctrl + Alt + T or search for βTerminalβ
βΆοΈ Step 2: Run the top Command
β€ Type:
β’ </>
β’ top
β’ Press Enter
π Step 3: Understand the Output
β€ top shows real-time system activity:
β CPU Usage β Percentage of CPU being used
β Memory Usage β RAM usage (used, free, cached)
β Load Average β System load over 1, 5, and 15 minutes
β Process List β Running programs with:
β’ PID (Process ID)
β’ %CPU usage
β’ %MEM usage
β’ Running time
β¨οΈ Step 4: Useful top Shortcuts
β€ While top is running:
β’ Press P β Sort by CPU usage
β’ Press M β Sort by Memory usage
β’ Press K β Kill a process (enter PID)
β’ Press Q β Quit top
πΉ Method 2: Using htop (User-Friendly Alternative)
π₯οΈ Step 1: Install htop (If Not Installed)ο»Ώ
β€ Ubuntu/Debian:
β’ </>
β’ sudo apt install htop
β€ CentOS/RHEL:
β’ </>
β’ sudo yum install htop
β€ macOS (with Homebrew):
β’ </>
β’ brew install htop
βΆοΈ Step 2: Run htop
β’ </>
β’ htop
β’ Press Enter.
π Step 3: Understand the Interface
β€ htop provides:
β’ Color-coded CPU usage bars
β’ Memory and Swap usage
β’ Scrollable process list
β’ Mouse support
β’ Easy process management
β¨οΈ Step 4: Useful htop Shortcuts
β’ F3 β Search for a process
β’ F4 β Filter processes
β’ F5 β Tree view
β’ F6 β Change sorting
β’ F9 β Kill process
β’ F10 β Exit
β When to Use top vs htop
Feature top htop
Pre-installed β Yes β Usually no
Color interface β No β Yes
Mouse support β No β Yes
Easier to use β οΈ Basic β More user-friendly
π― Pro Tips
β’ Use top on remote servers (always available).
β’ Use htop for easier monitoring and troubleshooting.
β’ Monitor high CPU processes to identify performance issues.
β’ If your system feels slow, check load average and memory usage first.