It looks like there is currently no way to do this as you request with terminal programs. What you ask is not new and actually is on htop
feature request list, but it has been that way for a year and a half and no milestone has been set to implement this yet. No sign of that at all for top
. 2 options could be:
1) Two terminals
You can tell top (e.g. you can use f
as it runs) to show the UID not the name. If you have split your terminal in 2 fields such as with terminator
or screen
then you can run top in the upper larger screen and query for the username in the lower e.g.
awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd
substituting whatever UID you want to look at for 1000. Of course, you could wrap it in a very small bash script so you should only type a few letters of your script name and the UID. Also if you are talking about non local users you can use getent passwd
as input for awk instead of /etc/passwd file - like so:
getent passwd | awk -v val=1000 -F ":" '$3==val{print $1}'
2) ps option
You could use ps to give you 15 most CPU heavy processes and who they belong to. You can vary the number of processes of course.
ps -ef | egrep -v "STIME|$LOGNAME" | sort -k4 -r | head -n 15 | colrm 100
Explanation:
ps -ef gives you all processes
egrep -v "STIME|$LOGNAME" removes the header line
sort -k4 -r sorts by the CPU column in reverse (biggest on top)
head -n 15 gives you first 15 lines of above
colrm 100 restricts each line of output to 100 characters
The last command is useful as some programs sch as google chrome have very long options lines after the command, so your output will be difficult to read if you don't cut the lines.
uname -a
uname -a