Nota Esta solução é específica do Mac OS. A versão do Linux é significativamente diferente.
top
não mostra o nome de usuário por padrão apenas o UID.
Você pode escolher quais colunas exibir com a opção -stats
.
Por exemplo
top -stats pid,user,cpu,command
mostrará o ID do processo, o nome do usuário, o uso da CPU e o comando
Processes: 167 total, 2 running, 4 stuck, 161 sleeping, 828 threads 09:55:43
Load Avg: 0.99, 1.31, 1.72 CPU usage: 7.6% user, 12.7% sys, 80.86% idle SharedLibs: 11M resident, 10M data, 0B linkedit. MemRegions: 46953 total, 2034M resident, 55M private, 708M shared.
PhysMem: 1166M wired, 2962M active, 849M inactive, 4977M used, 3213M free. VM: 402G vsize, 1054M framework vsize, 13229803(2) pageins, 816120(0) pageouts.
Networks: packets: 909991873/986G in, 888624532/347G out. Disks: 35379646/317G read, 10360185/448G written.
PID USER %CPU COMMAND
89849 root 0.0 installd
87409 corti 0.0 cookied
75165 root 8.4 top
75163 corti 0.0 mdworker
Você pode ver a lista com man top
:
pid Process ID (default).
command
Command name.
cpu CPU usage.
csw Number of context switches.
time Execution time.
threads
alias: th
Number of threads (total/running).
ports alias: prt
Number of Mach ports.
mregion
alias: mreg, reg
Number of memory regions.
rprvt Resident private address space size.
rshrd Resident shared address space size.
rsize Resident memory size.
vsize Total memory size.
vprvt Private address space size.
kprvt Private kernel memory size.
kshrd Shared kernel memory size.
pgrp Process group id.
ppid Parent process id.
state alias: pstate
Process state.
uid User ID.
wq alias: #wq, workqueue
The workqueue total/running.
faults alias: fault
The number of page faults.
cow alias: cow_faults
The copy-on-write faults.
user alias: username Username.
msgsent
Total number of mach messages sent.
msgrecv
Total number of mach messages received.
sysbsd Total BSD syscalls.
sysmach
Total Mach syscalls.
pageins
Total pageins.