How is the linux top command used?

The Linux top command is used to monitor real-time process activity and system performance. It dynamically displays the list of currently running processes and provides detailed information about each process, such as process ID, CPU usage, memory usage, process priority, etc.

Here are some commonly used options and usage of the top command:

  1. Run the “top” command directly: Input “top” in the terminal to display the current system’s process list and performance information.
  2. Sort processes by CPU usage: Press Shift+P to arrange processes in descending order based on CPU usage.
  3. Sort by memory usage: Press Shift + M to order processes by memory usage from highest to lowest.
  4. To end a process: press the ‘k’ key, then enter the PID of the process you want to terminate to stop the specified process.
  5. Switch display modes: press the capital letter E key to toggle between display modes, including cumulative mode, interval mode, and average mode.
  6. Set refresh interval: press the “s” key, then enter the number of seconds for the refresh interval, to set the refresh interval for the top command, default is 3 seconds.
  7. Display processes for a specific user: Add the -u option after the top command, then input the username to only show processes for that user.
  8. Displaying specific process information: Adding the -p option after the top command and entering the process ID allows for only displaying information about a specific process.
  9. Press the “f” key to hide or display specific columns, such as process ID, CPU usage, memory usage, etc.
  10. To exit the top command, press the q key.

These are some common options and usages of the top command, which allows users to monitor system processes and performance metrics in real-time, helping them understand the system’s operation.

bannerAds