What is the difference between ps and top command ? I see that both can display information about running processes . Which one should be used when ?


top is mostly used interactively (try reading man page or pressing "h" while top is running) and ps is designed for non-interactive use (scripts, extracting some information with shell pipelines etc.)

| improve this answer | |

top allows you display of process statistics continuously until stopped vs. ps which gives you a single snapshot.

| improve this answer | |

top enables you to see your processes ordered by the amount of processor power they use. ps enables you to see all your processes, or just the processes used by certain users, for example root or yourself.

top should be used to see which processes are most active, ps could be used to see which processes you (or any other user) are running currently.

for more information about how to use top and ps, run man top or man ps in your terminal ;)

| improve this answer | |

Another point:

ps - Reading Process(ps) Information
top - Resource Monitoring like top resources using cpu, memory usage and more.

| improve this answer | |

For CPU usage, ps displays average CPU usage over the lifetime of the process as it is instantaneous and would always be 0% or 100%. top gives a more instantaneous look at it from averaging over recent polls.

More information here: Top and ps not showing the same cpu result

| improve this answer | |
  • The average CPU usage (%CPU) could be anything between 0 and 100% (inclusive). According to the procps-ng man page, It will not add up to 100% unless you are lucky. – Anthony Geoghegan Jan 30 '19 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.