Software & Apps Linux 70 70 people found this article helpful How to Use the Linux 'top' Command to Show Running Processes A real-time system resource monitor helps alert you to system bottlenecks by Gary Newell Writer Gary Newell was a freelance contributor, application developer, and software tester with 20+ years in IT, working on Linux, UNIX, and Windows. our editorial process Gary Newell Updated on July 03, 2020 Linux Switching from Windows Tweet Share Email The Linux top command shows the running processes within your Linux environment that consume the most system resources. How to Run the 'top' Command In its basic form all you need to do to show the current processes is type the following in a Linux terminal: Command Output The top command runs in the foreground and continuously updates itself. Its results show on five lines, plus the main table. Line 1 The first line offers some basic high-level info about the system: The timeHow long the computer has been runningNumber of usersLoad average The load average shows the system load time for the last 1, 5 and 15 minutes. Line 2 The second line summarizes the number of ongoing, concurrent tasks: Total number of tasksNumber of running tasksNumber of sleeping tasksNumber of stopped tasksNumber of zombie tasks Line 3 The third line summarizes CPU performance: CPU usage as a percentage by the userCPU usage as a percentage by systemCPU usage as a percentage by low priority processesCPU usage as a percentage by idle processesCPU usage as a percentage by io waitCPU usage as a percentage by hardware interruptsCPU usage as a percentage by software interruptsCPU usage as a percentage by steal time ItStillWorks: CPU Usage Line 4 The fourth line emphasizes memory: Total system memoryFree memoryMemory usedBuffer cache Line 5 The fifth line highlights available swap space and total memory inclusive of swap: Total swap availableTotal swap freeTotal swap usedAvailable memory Answers to Questions About Using a Swap Partition in Linux Main Table The main table lists running processes: Process IDUserPriorityNice levelVirtual memory used by processResident memory used by a processShareable memoryCPU used by process as a percentageMemory used by process as a percentageTime process has been runningCommand Check out your distribution's package manager for alternative versions of this utility that offer more or different functionality. Key Switches for the 'top' Command Although you invoke top just by typing the name in a shell session, a few switches modify the utility's behavior: -h: Show the current version-c: This toggles the command column between showing command and program name-d: Specify the delay time between refreshing the screen-o: Sorts by the named field-p: Only show processes with specified process IDs-u: Show only processes by the specified user-i: Do not show idle tasks Adding Extra Columns to the Display Press F to show the list of fields displayable in the table. Use the arrow keys to move up and down the list of fields. To display or hide a field on the screen, press D to toggle it. An asterisk appear next to manually displayed fields. Set the field to sort the table by simply by pressing the "S" key on the field you wish to sort by. Press the enter key to commit your changes and press "Q" to quit. Toggling Modes Whilst running top press A to toggle between the standard display and an alternate display. Changing Colors Press Z to change the colors of the values within top. Three stages change the colors: Press either S for summary data, M for messages, H for column headings or T for task information to target that area for a color changeChoose a color for that target, 0 for black, 1 for red, 2 for green, 3 for yellow, 4 for blue, 5 for magenta, 6 for cyan and 7 for whiteEnter to commit. Press B to make text bold. Change the Display While Running 'top' While the command runs in the foreground, toggle many features on and off by pressing relevant keys. The following table shows the key to press and the function it provides: Function Key Description A Alternative display (default off) d Refresh screen after specified delay in seconds (default 1.5 seconds) H Threads mode (default off), summarises tasks p PID Monitoring (default off), show all processes B Bold enable (default on), values are shown in bold text l Display load average (default on) t Determines how tasks are displayed (default 1+1) m Determines how memory usage is displayed (default 2 lines) 1 Single cpu (default off) - i.e. shows for multiple CPUs J Align numbers to the right (default on) j Align text to the right (default off) R Reverse sort (default on) - Highest processes to lowest processes S Cumulative time (default off) u User filter (default off) show euid only U User filter (default off) show any uid V Forest view (default on) show as branches x Column highlight (default off) z Color or mono (default on) show colors Function Keys Alternative: 'htop' Utility It's not installed on most distributions by default, but the htop utility functions similarly to top but it streamlines the display and ties behavior to real-time function key presses rather than a complex menu of letter-and-switch behavior. Significantly, htop shows all running processes whereas top focuses on the top processes that consume the most system resources. More from Lifewire A Beginner's Guide to Conky Example Uses of the Command 'ps' How to Prevent Firefox From Using Too Much Memory How to Use the 'init' Command in Linux How to Use the Netstat Command on Mac How to Kill Processes Using Linux Linux Command/Unix Command — display The 5 Most Useful GIMP Keyboard Shortcuts signal — Linux/Unix Command Task Manager: A Complete Walkthrough 15 Linux Terminal Commands That Will Rock Your World 10 Essential Linux Commands for Navigating Your File System 5 Ways to Kill a Linux Program How to Use the Sudo Command in Linux inittab—Linux / Unix Command Learn About the Linux Command 'free'