146

I'm running a Rails stack on Ubuntu.

When I call ps -AF, I get a descriptive process name set by the Apache module like

00:00:43 Rails: /var/www...

which is really helpful in diagnosing load issues.

But when I call top, the same process shows up simply as

ruby

Is there any way to get the ps -AF process name in top?

Matthias Braun
  • 225
  • 1
  • 8
Ben K.
  • 2,379
  • 4
  • 18
  • 15

6 Answers6

262

While top is running, you can press c to toggle between showing the process name and the command line. To remember the toggle state for next time, press W to save the current configuration to ~/.toprc.

Phil Ross
  • 7,279
  • 2
  • 24
  • 19
28

This is more of a general suggestion, than an answer:

Try out htop. It shows the full process name by default and I think it's much easier to use.

Trey Hunner
  • 1,282
  • 10
  • 9
  • 3
    great! much better than the raw 'top'. thanks a lot! – Siwei May 17 '13 at 00:32
  • 1
    so a word of caution with htop, it is prettier and more flexible, but I've noticed if you leave it running for a long time, it starts to be wrong. I notice if you have the main display sorted by CPU and wait a day or so, and lots of different processes start using different amounts of cpu, it will stop showing the most cpu intensive ones at the top even though that's the current sort order. just something I've noticed over the years. – Stu Dec 18 '22 at 21:49
19

top -c -n 1 should give you what you want.

  • -c: automatically toggles between command line and program name
  • -n 1: this makes top to exit out immediately without showing the updates every 3 seconds (by default)
Jaeyoung Chun
  • 291
  • 2
  • 3
6

When running top type c to toggle command line/process.

user9517
  • 115,471
  • 20
  • 215
  • 297
1

You could either press c while top is running or use htop. But, if I may, give glances a look as well. It could serve as an alternative.

Glances Home

I use it quite a bit and is really handy!

vnay92
  • 111
  • 2
0

You can also press h to get the full list of commands.