We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Top

The top command is a powerful tool that allows you to see which programs are using the most resources on your computer.

I use the top command all the time, both on my local machine and on remote servers to diagnose performance issues. If you've ever opened up your task manager on Windows or Activity Monitor on macOS, top is similar, but for the command line.

Assignment

  1. Notice that the top command runs in a loop, updating the information every few seconds.

    By default, top sorts the processes by CPU usage, with the most CPU-intensive processes at the top. Another useful resource to sort by is memory (RAM) usage:

    Linux/WSL

    Press M (uppercase) while top is running.

    macOS

    You can either start top sorted by memory with top -o mem from the shell, or, while top is running, press O, then type mem and press Enter to sort by memory.

  2. Don't submit yet.

Submit the column names that you copied into the text box on the right.

Tips

  • top might not print some columns if your terminal window isn't wide enough to fit them. Try to resize your window or zoom out (reduce font size) and ensure that you print all columns. Otherwise, your submission might fail.
  • If you resize your terminal window while top is running, make sure to quit and restart the top command to ensure all columns are displayed correctly.
  • If your system is set up with a non-English locale, make sure that your printed output matches the expected output by running this instead:
    LANG=C top