17

In top screen, by default it shows all users' processes. How to exclude some users(for example, root and nobody) from the top real-time screen?

Khaled
  • 36,533
  • 8
  • 72
  • 99
garconcn
  • 2,388
  • 8
  • 35
  • 46

4 Answers4

19

The correct answer is: -U '!root' (or -u '!root' on some Ubuntus). This was introduced in top v3.2.9:

man top for -U option:

Prepending an exclamation point ('!') to the user id or name instructs top to display only processes with users not matching the one provided.

Remember to put the exclamation mark and username in single quotes.

milan
  • 370
  • 3
  • 11
4

Also, as of version 3.3, you can just type u while top is running and enter that !root string.

Dr Bombay
  • 41
  • 1
2

top -U root shows only processes from root. Unfortunately that is the only option for limiting users according to the man page.

Tim
  • 3,017
  • 17
  • 15
  • But if you wanted to deviate from using top, you could do `ps aux | grep -v $USERNAME` to see all processes except the user you specified. – Tim Jan 06 '12 at 18:14
  • Thanks. I know those two commands. I've searched around but didn't find anyone ask about this. top -u can see one user, but I want to see more users in real-time. – garconcn Jan 06 '12 at 18:22
  • 4
    top | egrep -ve "(root|knoppix)"? Modify to suit your requirements. – dtbnguyen Jan 07 '12 at 02:52
1

As suggested by Dr Beco above the most general filtering mechanism uses 'o/O' to activate "Other Filtering" while in top to exclude/include more than one user.

For example to exclude "root" and "nobody" one can use the command o!USER=root<enter>o!USER=nobody.

Many interesting views are possible with this filtering option!

Kapil
  • 221
  • 1
  • 2
  • I think this is the only answer that answers the question: "exclude some users (for example, root and nobody)", i.e. excluding more than one user. Perhaps this wasn't possible in 2012. – Ramashalanka Mar 05 '19 at 22:56