2

I often use top under bash. I would like to highlight (in color, bold or other form) my user name, so that I can more easily find it in top. (Sometimes it's difficult with many users running lots of processes...)

Is this possible and if yes, how?

1
  • Do you know htop... it has some nice features (my favorite is F5 = process tree) and it does highlight the current user by default.
    – mpy
    Commented Apr 5, 2013 at 13:18

2 Answers 2

1

Run top and press h for help

The requested functionality is described on lines 4, 12 and 13. Info on line 20 is also very useful.

    
 1  Help for Interactive Commands - procps-ng version 3.3.4
 2  Window 1:fie: Cumulative mode Off.  System: Delay 2.0 secs; Secure mode Off.
 3
 4    Z,B       Global: 'Z' change color mappings; 'B' disable/enable bold
 5    l,t,m     Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info
 6    1,I       Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode
 7    f,F,X     Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-width
 8
 9    L,&,<,> . Locate: 'L'/'&' find/again; Move sort column: '<'/'>' left/right
10    R,H,V,J . Toggle: 'R' Sort; 'H' Threads; 'V' Forest view; 'J' Num justify
11    c,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justify
12    x,y     . Toggle highlights: 'x' sort field; 'y' running tasks
13    z,b     . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
14    u,U     . Show: 'u' effective user; 'U' real, saved, file or effective user
15    n or #  . Set maximum tasks displayed
16    C,...   . Toggle scroll coordinates msg for: up,down,left,right,home,end
17
18    k,r       Manipulate tasks: 'k' kill; 'r' renice
19    d or s    Set update interval
20    W         Write configuration file
21    q         Quit
22            ( commands shown with '.' require a visible task display window )
23  Press 'h' or '?' for help with Windows,
24  any other key to continue

1

Why not use:

top -u <username>

It will only show your processes:

top - 04:55:43 up 70 days, 10:31, 33 users,  load average: 7.85, 9.06, 10.79
Tasks: 2726 total,   4 running, 2601 sleeping,  41 stopped,  80 zombie
Cpu(s): 12.5%us,  2.5%sy,  0.0%ni, 71.1%id, 13.6%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:  132145112k total, 131823100k used,   322012k free,    10632k buffers
Swap: 52428796k total, 25676880k used, 26751916k free, 11606048k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2611 <username>  20   0 20148 3336  908 R  2.3  0.0   0:03.39 top
 6472 <username>  20   0  109m 2224 1168 S  0.0  0.0   0:00.02 sshd
 8239 <username>  20   0  109m 2204 1160 S  0.0  0.0   0:00.01 sshd
 8247 <username>  20   0 14812 2036 1292 S  0.0  0.0   0:00.06 bash
32315 <username>  20   0  109m 2232 1164 S  0.0  0.0   0:00.18 sshd
32320 <username>  20   0 14548 1816 1312 S  0.0  0.0   0:00.03 bash
2
  • Because it does not highlight anything with the default settings. Commented Apr 5, 2013 at 23:54
  • Because, then obviously I don't see the other users anymore. If I use -u username why would I want to highlight in the first place.
    – user50105
    Commented Apr 8, 2013 at 7:23

You must log in to answer this question.