1

When I run top, after having looked at all currently running processes, I often want to filter down to only my own processes. So I hit u, type my user name and hit Enter.

However, in our company, Unix user names follow the firstname_lastname pattern which can become cumbersome to type when you have a long name. So I wonder if there is any shortcut to interactively only showing the current user’s processes? (similar to simply hitting Enter after hitting u to see all processes again)

3
  • Not interactive, but you could define alias utop='top -u first_last' and run utop in a different terminal. Or, just keep a scratchpad vi open with all those long strings you keep mistyqing, so you can just paste them whenever. Commented Feb 10, 2020 at 11:47
  • you can use top -u and add a variable that outputs the logged user. something like top -u $(whoami)and that should output the processes of the user that is logged in the session.
    – BANJOSA
    Commented Feb 10, 2020 at 12:05
  • 1
    @BANJOSA: the question aksed about doing it in top interactive mode. Commented Feb 10, 2020 at 12:15

1 Answer 1

3

Yes,

you can use the user id instead. This works both in interactive mode and using command line options

man top
-u | -U  :User-filter-mode as:  -u | -U number or name
            Display  only  processes  with a user id or user name matching that given.
2
  • Unfortunately, I don’t have the same user ID on all hosts that I connect to. But this may at least be better than using a user name on some hosts, so +1, thanks! I still wonder if there is no better solution, without having to memorize user IDs …
    – Chriki
    Commented Feb 10, 2020 at 14:34
  • Just run top -u $UID or create an alias for it. Your shell knows your UID. Commented Jan 19 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .