How to Use Terminal to Monitor System Performance (top/htop)

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 β†’ 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.

Tags

Categories

  • Hints 237