Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
2 answers
6871 views
Why is memory (rss) from ps command different than memory seen in top command?
Here on MacOS Catalina, when checking the memory usage of a process I see that the `ps` command shows a RSS value which is different from the memory usage shown in top: ``` $> ps e -o command,vsize,rss,%mem|grep "myapplication"|head -n 1 myapplication 4594896 51364 0.3 ``` **RSS -> 51364** ``` top P...
Here on MacOS Catalina, when checking the memory usage of a process I see that the ps command shows a RSS value which is different from the memory usage shown in top:
$> ps e -o command,vsize,rss,%mem|grep "myapplication"|head -n 1
myapplication  4594896  51364  0.3
**RSS -> 51364**
top
PID    COMMAND       %CPU TIME    #TH             #WQ  #PORT MEM    
48106  myapplication 115.7        09:06.12 69/1   1    101   37M+
**MEM -> 37M** Why this difference? **UPDATE:** Another example with IntelliJ process:
top -pid 357
PID  COMMAND      %CPU TIME     #TH   #WQ  #POR MEM    PURG CMPRS  PGRP PPID STATE    BOOSTS        %CPU_ME %CPU_OTHRS UID       FAULTS    COW   MSGSENT  MSGRECV  SYSBSD
357  idea         2.6  03:16:46 112   1    925  4906M  0B   1583M  357  1    sleeping  0      0.00000 0.00000    281451937 28337096  54627 8404446+ 2733245+ 156093159+
Top shows **4906M**
ps aux
USER               PID  %CPU %MEM        VSZ    RSS   TT  STAT STARTED      TIME COMMAND

xxxxxxx            357   3.6 14.5 180050484 2430728   ??  S     1:44PM 196:48.70 /Applications/IntelliJ IDEA.app/Contents/MacOS/idea -psn_0_73746
ps shows RSS **2430728** (KB)
codependent (123 rep)
Mar 30, 2020, 12:01 PM • Last activity: Jul 26, 2025, 04:06 PM
1 votes
1 answers
46 views
Excluding processes by one user in Solaris "top"
Host machine: SunOS 5.11 11.3 sun4v sparc sun4v As an Informix DBA monitoring a system I am trying to see the top users of CPU. In an Informix environment, that slot is hogged by a gazillion instances of and the engine, being run as user `informix`. I have seen a few suggestions of excluding a given...
Host machine: SunOS 5.11 11.3 sun4v sparc sun4v As an Informix DBA monitoring a system I am trying to see the top users of CPU. In an Informix environment, that slot is hogged by a gazillion instances of and the engine, being run as user informix. I have seen a few suggestions of excluding a given user but none of them work. Examples: - Press the "o" key exclude the user by entering !USER=informix. No, when I press the o key it prompts me for a sort column. - On the command line: top -u='!informix' (or something similar). It ignores that, though it does not complain about the command line option. Or maybe it does but that flashes by too quickly as the interactive screen comes on. Hey, I'm open to suggestions here. Ideas? A fool's quest? Thanks for help here. -- JS
Jacob Salomon (111 rep)
May 26, 2025, 11:25 PM • Last activity: May 27, 2025, 07:37 AM
4 votes
1 answers
2107 views
System Usage 80% and User CPU usage 20%
Company purchased HP Gen 9 Server to be used for Oracle Applications. Today while doing daily system check Top show that System Area CPU Usage is 80%(Certainly not normal)while User Area Usage is 17-20%(which is normal). I checked for RAM (Installed Ram is 64 GB) and vmstat shows its not Memory issu...
Company purchased HP Gen 9 Server to be used for Oracle Applications. Today while doing daily system check Top show that System Area CPU Usage is 80%(Certainly not normal)while User Area Usage is 17-20%(which is normal). I checked for RAM (Installed Ram is 64 GB) and vmstat shows its not Memory issue and there is no swapping going on. And i checked with APPDBA and he said he is not facing any issue related to any delay everything is working OK from his end. TOP Result =========== TOP Command output VMSTAT Result ============= enter image description here Any idea what i'm missing.....
OmiPenguin (4398 rep)
Nov 28, 2017, 07:14 AM • Last activity: May 25, 2025, 01:00 PM
612 votes
10 answers
1083711 views
How to display `top` results sorted by memory usage in real time?
How can I display the `top` results in my terminal in real time so that the list is sorted by memory usage?
How can I display the top results in my terminal in real time so that the list is sorted by memory usage?
Theodor Coogan (6121 rep)
May 11, 2014, 08:27 PM • Last activity: May 23, 2025, 01:08 PM
1 votes
1 answers
128 views
How to measure actual CPU utilization in Linux for multi core applications?
I have a computation intensive process that I need to run multiple times on a multi-core processor but "top" isn't showing utilization or load in a useful way. For example, imagine my task runs in 1 minute in a single thread on a single core of my six core, 12 thread, SMT CPU. If I start the same ta...
I have a computation intensive process that I need to run multiple times on a multi-core processor but "top" isn't showing utilization or load in a useful way. For example, imagine my task runs in 1 minute in a single thread on a single core of my six core, 12 thread, SMT CPU. If I start the same task six times using six threads, it still finishes in 1 minute and top shows the load average as 6.0 and the cpu(s) at 50% us and 50% id. In the top process list, each of the six processes is showing 100% CPU. If I do the same thing but start 12 threads, it finishes the 12 jobs in 2 minutes and top shows the load average as 12.0, cpu(s) at 100% us 0% id, with 12 processes each at 100% CPU. Now, the 6 thread and 12 thread examples are both processing at the same fully loaded rate of completing 1/6 job per minute but why does top show the 6-thread case being 50% idle when clearly it isn't? Is there a better way of determining the actual load of the CPUs? This was run on a Ryzen 5600X processor on Ubuntu 24.12. Edit: top output for 12 tasks:
top - 08:35:37 up 54 days, 20:49,  3 users,  load average: 12.20, 6.70, 2.80
Tasks: 346 total,  13 running, 332 sleeping,   0 stopped,   1 zombie
%Cpu(s): 98.2 us,  1.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st 
MiB Mem :  64221.7 total,   1572.7 free,   4983.4 used,  58684.1 buff/cache     
MiB Swap:   8192.0 total,   7863.7 free,    328.3 used.  59238.3 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                
2249765 user    20   0  126952  64132  51200 R 100.0   0.1   3:48.87 sonicLiquidFoam                                        
2249759 user    20   0  127060  64220  51200 R 100.0   0.1   3:48.93 sonicLiquidFoam                                        
2249757 user    20   0  126624  64064  51328 R 100.0   0.1   3:49.32 sonicLiquidFoam                                        
2249761 user    20   0  128276  64868  50688 R 100.0   0.1   3:47.65 sonicLiquidFoam                                        
2249762 user    20   0  127652  63688  50432 R 100.0   0.1   3:49.13 sonicLiquidFoam                                        
2249755 user    20   0  128844  66128  51200 R 100.0   0.1   3:46.06 sonicLiquidFoam                                        
2249766 user    20   0  126576  63952  51328 R 100.0   0.1   3:47.87 sonicLiquidFoam                                        
2249764 user    20   0  126612  63824  51072 R  99.0   0.1   3:48.59 sonicLiquidFoam                                        
2249760 user    20   0  126888  63972  51072 R  98.7   0.1   3:45.06 sonicLiquidFoam                                        
2249758 user    20   0  127500  64860  51200 R  97.7   0.1   3:48.64 sonicLiquidFoam                                        
2249763 user    20   0  127916  64944  51072 R  97.0   0.1   3:39.58 sonicLiquidFoam                                        
2249756 user    20   0  126828  63948  51072 R  96.0   0.1   3:48.77 sonicLiquidFoam
For 6 tasks:
top - 08:40:22 up 54 days, 20:53,  3 users,  load average: 6.11, 6.67, 3.90
Tasks: 335 total,   7 running, 327 sleeping,   0 stopped,   1 zombie
%Cpu(s): 50.0 us,  1.0 sy,  0.0 ni, 49.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st 
MiB Mem :  64221.7 total,   1616.2 free,   4914.6 used,  58710.3 buff/cache     
MiB Swap:   8192.0 total,   7863.7 free,    328.3 used.  59307.1 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                
2250032 user    20   0  127392  64676  51200 R 100.0   0.1   2:39.15 sonicLiquidFoam                                        
2250027 user    20   0  126828  63096  50176 R 100.0   0.1   2:39.23 sonicLiquidFoam                                        
2250028 user    20   0  127060  63260  50176 R 100.0   0.1   2:39.23 sonicLiquidFoam                                        
2250029 user    20   0  128844  66124  51200 R 100.0   0.1   2:39.12 sonicLiquidFoam                                        
2250030 user    20   0  128276  65508  51200 R 100.0   0.1   2:39.21 sonicLiquidFoam                                        
2250031 user    20   0  126596  63808  51072 R 100.0   0.1   2:39.21 sonicLiquidFoam
tkw954 (113 rep)
Apr 23, 2025, 07:35 PM • Last activity: Apr 24, 2025, 02:43 PM
7 votes
2 answers
473 views
Why are there so few "running" processes?
On all of BSD/Linux/MacOS and Solaris, I made an observation - no matter how busy the system is, `top` always reports very few (usually 1-2) running processes. According to my limited understanding, a process is in "running" state if it is using CPU time, or waiting for CPU time to become available....
On all of BSD/Linux/MacOS and Solaris, I made an observation - no matter how busy the system is, top always reports very few (usually 1-2) running processes. According to my limited understanding, a process is in "running" state if it is using CPU time, or waiting for CPU time to become available. So, here is a scenario: I use SSH to tunnel VNC, then run top on remote machine, in a Terminal emulator: - top itself is listed as a "running" process (understandable) - sshd is listed, but not "running" - Xvnc is listed, but not "running" But sshd is tunneling VNC traffic, Xvnc is what keeps me updated with screen content, how can they not be using CPU time? If they are using CPU time, then how come they are not "running"?
Howard (5279 rep)
Nov 29, 2013, 01:19 PM • Last activity: Apr 2, 2025, 10:01 PM
5 votes
2 answers
378 views
Automatic or manual screen session termination
I've created a `screen` session and ran `rsync` within that session: screen -S rsync_backup rsync -rvnc data/ data2 >rsync_out-4.txt 2>rsync_outErr-4.txt I used the `top` command for progress monitoring and initially I saw both the `screen` and `rsync` in the `top` output (toy example is below): PID...
I've created a screen session and ran rsync within that session: screen -S rsync_backup rsync -rvnc data/ data2 >rsync_out-4.txt 2>rsync_outErr-4.txt I used the top command for progress monitoring and initially I saw both the screen and rsync in the top output (toy example is below): PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1619 denis 20 0 170096 4644 0 S 0.0 0.0 0:00.00 rsync 1739 denis 20 0 7320 2828 2064 S 0.0 0.0 0:00.02 screen Some time later there was no rsync, but screen still be present in the top output: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1739 denis 20 0 7320 2828 2064 S 0.0 0.0 0:00.02 screen My questions are: 1. Should screen session automatically terminated when command (rsync in my case) running within that session will be finished? 2. Does typical user scenario assume mandatory manual screen session killing after command (e.g. rsync) execution finishing? I.e.:
screen -S rsync_backup

rsync -rvnc data/ data2 >rsync_out-4.txt 2>rsync_outErr-4.txt
screen -XS  quit
Denis (153 rep)
Mar 18, 2025, 01:37 PM • Last activity: Mar 19, 2025, 11:54 AM
1 votes
0 answers
66 views
How do i list all consuming program by cpu, memory
I want to list all CPU- and memory-consuming programs. There are a bunch of `top` commands and questions about this, but none of them list programs properly. For example, a Python web service could spawn multiple processes. I want to sum all of them if they originate from the same path or program ID...
I want to list all CPU- and memory-consuming programs. There are a bunch of top commands and questions about this, but none of them list programs properly. For example, a Python web service could spawn multiple processes. I want to sum all of them if they originate from the same path or program ID. Is there a way to group and list them by ppid or path?
TomSawyer (133 rep)
Jan 31, 2023, 03:42 AM • Last activity: Mar 17, 2025, 01:30 PM
3 votes
3 answers
648 views
Tool for viewing top N items in stream
I'm looking for an existing Linux command-line tools that can accomplish the following: Consider there is an input stream `/dev/inputstream` which spews an infinite stream of data that looks like this: A A B A C Z A . . . **NOTE:** (Each line is one character from the alphabet). The tool is used in...
I'm looking for an existing Linux command-line tools that can accomplish the following: Consider there is an input stream /dev/inputstream which spews an infinite stream of data that looks like this: A A B A C Z A . . . **NOTE:** (Each line is one character from the alphabet). The tool is used in the following fashion: cat /dev/inputstream | tool The output of the tool should be like the one from "top" command. It should be a continuously updated list of top N frequently occurring items. Eg: A -- 10 times B -- 8 times Z -- 7 times C -- 2 times D -- 1 time If the stream were not infinite I could have accomplished this using sort and uniq.
Prashanth Ellina (199 rep)
May 15, 2014, 06:18 PM • Last activity: Mar 5, 2025, 06:33 AM
324 votes
17 answers
504807 views
How to monitor CPU/memory usage of a single process?
I would like to monitor one process's memory / cpu usage in real time. Similar to `top` but targeted at only one process, preferably with a history graph of some sort.
I would like to monitor one process's memory / cpu usage in real time. Similar to top but targeted at only one process, preferably with a history graph of some sort.
Josh K (4066 rep)
Aug 17, 2010, 03:21 AM • Last activity: Feb 3, 2025, 01:46 PM
3 votes
2 answers
3154 views
Monitor the processes of multiple users with top
Is it possible to monitor processes of multiple (but not all) users in Linux using `top`? Something of this kind: ```lang-sh top -u user1 -u user2 ```
Is it possible to monitor processes of multiple (but not all) users in Linux using top? Something of this kind:
-sh
top -u user1 -u user2
S.V (141 rep)
Jul 10, 2018, 01:42 PM • Last activity: Jan 16, 2025, 03:24 PM
2 votes
3 answers
98 views
how to auto wrap top command output
When I use the top command in linux terminal: top -c the output like this: top - 21:54:17 up 197 days, 6:34, 1 user, load average: 0.10, 0.65, 1.47 Tasks: 255 total, 1 running, 200 sleeping, 0 stopped, 54 zombie %Cpu(s): 6.0 us, 4.5 sy, 0.0 ni, 87.4 id, 0.5 wa, 1.0 hi, 0.5 si, 0.0 st MiB Mem : 3625....
When I use the top command in linux terminal: top -c the output like this: top - 21:54:17 up 197 days, 6:34, 1 user, load average: 0.10, 0.65, 1.47 Tasks: 255 total, 1 running, 200 sleeping, 0 stopped, 54 zombie %Cpu(s): 6.0 us, 4.5 sy, 0.0 ni, 87.4 id, 0.5 wa, 1.0 hi, 0.5 si, 0.0 st MiB Mem : 3625.3 total, 119.0 free, 2408.5 used, 1097.9 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 936.8 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1398379 root 20 0 2498248 92148 20716 S 3.0 2.5 2055:04 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/k+ 1403326 root 20 0 1892712 560052 27112 S 2.7 15.1 2502:04 kube-apiserver --advertise-address=172.31.227.20 --allow-privileged=true --authorization-mode=Node+ 1428214 root 20 0 1402944 125200 9776 S 1.3 3.4 801:06.55 cilium-agent --config-dir=/tmp/cilium/config-map 3848379 root 20 0 269028 27268 7500 S 1.3 0.7 256:37.39 /usr/local/aegis/aegis_client/aegis_12_43/AliYunDunMonitor 791206 root 20 0 125488 17484 11720 S 1.0 0.5 0:00.10 /usr/local/aegis/AliSecCheck/AliSecCheck -t rtap -c Rtap20483038711736690048 1399005 I can see part of the command content, how to auto wrap the command when the commend is too long? I have tried: [root@iZm5e2jhfbrshckqh6qdbuZ poemhub]# top -bcn1 -w100 top - 21:55:33 up 197 days, 6:35, 1 user, load average: 0.47, 0.70, 1.42 Tasks: 252 total, 2 running, 196 sleeping, 0 stopped, 54 zombie %Cpu(s): 5.9 us, 5.9 sy, 0.0 ni, 85.3 id, 0.0 wa, 2.9 hi, 0.0 si, 0.0 st MiB Mem : 3625.3 total, 139.8 free, 2395.4 used, 1090.1 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 949.4 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 866186 root 20 0 22024 4932 3432 S 6.2 0.1 7:10.58 ./cv-render 1398379 root 20 0 2498248 89164 20720 S 6.2 2.4 2055:06 /usr/bin/kubelet --bootstra+ 1404790 65532 20 0 1287016 21224 0 S 6.2 0.6 206:58.70 /coredns -conf /etc/coredns+ 1 root 20 0 387308 7460 3072 S 0.0 0.2 1324:21 /usr/lib/systemd/systemd --+ 2 root 20 0 0 0 0 S 0.0 0.0 0:04.12 [kthreadd] 3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [rcu_gp] 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 [rcu_par_gp] this just hidden the output, not wrap the output, I still want to see the full output. I also tried like this: top -c -w 512|fold -w 120 -s the wrap works, but the command did not output the full, just using + at the end of command.
Dolphin (791 rep)
Jan 12, 2025, 01:56 PM • Last activity: Jan 12, 2025, 09:50 PM
6 votes
2 answers
23068 views
In Linux, top command sort by field "TIME+" using command line, iterations 1 time
When we run top command and If we type "T", it will sort based on the TIME+ I want to sort by "TIME+" in command line, using top -n 1 so that I can capture all the process in a file and analyse it one by one. Note: It is CentOs
When we run top command and If we type "T", it will sort based on the TIME+ I want to sort by "TIME+" in command line, using top -n 1 so that I can capture all the process in a file and analyse it one by one. Note: It is CentOs
Mani (634 rep)
Feb 9, 2017, 01:19 PM • Last activity: Jan 12, 2025, 08:52 AM
7 votes
2 answers
1152 views
Understanding Linux 'top' command: Memory vs Swap display format confusion
Does the "avail Mem" value actually relate to physical memory rather than swap, despite being displayed on the swap line? I noticed there's a period at the end of the "swap used" column.
Does the "avail Mem" value actually relate to physical memory rather than swap, despite being displayed on the swap line? I noticed there's a period at the end of the "swap used" column.
Just a learner (2022 rep)
Nov 23, 2024, 06:56 AM • Last activity: Nov 23, 2024, 07:28 PM
29 votes
4 answers
39143 views
Is there an equivalent to top but for network I/O?
Is there a program that I can use to list processes based on their current network I/O usage? `top` does CPU, and on FreeBSD at least, it will also do disk I/O if you pass it `-m io` (I assume that there's an equivalent of some kind on Linux, but I don't remember it off the top of my head). But what...
Is there a program that I can use to list processes based on their current network I/O usage? top does CPU, and on FreeBSD at least, it will also do disk I/O if you pass it -m io (I assume that there's an equivalent of some kind on Linux, but I don't remember it off the top of my head). But what I'd like is specifically network I/O so that I can see which processes are using it and how much. Is there a program that I can use to list processes that way? And if not, what would be the best alternative?
Jonathan M Davis (1377 rep)
Jun 4, 2016, 11:29 PM • Last activity: Nov 13, 2024, 04:12 PM
8 votes
5 answers
37286 views
How can I automatically kill the process with the highest CPU load?
Sometimes programs will lock up in the background and cause high CPU usage. Is there any way I can programmatically ascertain which process is causing the highest CPU load at the moment and kill it?
Sometimes programs will lock up in the background and cause high CPU usage. Is there any way I can programmatically ascertain which process is causing the highest CPU load at the moment and kill it?
Glutanimate (2328 rep)
Sep 11, 2013, 12:46 AM • Last activity: Oct 7, 2024, 06:30 AM
3 votes
2 answers
3953 views
Is there a way to collapse the list of processors in htop?
Now that I have a computer with 64 processors, I have a real display problem with `htop`. When I look at the screen in my console, all I see are the 64 processors and nothing about what's running (well, one line). Under X-Windows I can make the console bigger with F11 , but that means I can't see my...
Now that I have a computer with 64 processors, I have a real display problem with htop. When I look at the screen in my console, all I see are the 64 processors and nothing about what's running (well, one line). Under X-Windows I can make the console bigger with F11, but that means I can't see my other windows. When I use top, I can hit the 1 key and either all the CPUs are shown or collapsed into just one entry. Do we have a way to do that in htop? I have to say that having _too many CPUs_ renders htop rather useless in that sense.
Alexis Wilke (3095 rep)
Jan 2, 2020, 09:14 PM • Last activity: Sep 23, 2024, 01:13 AM
0 votes
1 answers
250 views
Command-line option to disable too many processes in htop
By default, `htop` shows many more processes than other tools (top, ps). The solution is to press `H`, as mentionned in [Why are there many processes listed under the same title in htop?](https://superuser.com/questions/118086/why-are-there-many-processes-listed-under-the-same-title-in-htop), to get...
By default, htop shows many more processes than other tools (top, ps). The solution is to press H, as mentionned in [Why are there many processes listed under the same title in htop?](https://superuser.com/questions/118086/why-are-there-many-processes-listed-under-the-same-title-in-htop) , to get the "usual" shorter process list. With which command-line argument should we run htop, to have this behaviour?
Basj (2579 rep)
Sep 6, 2024, 08:27 AM • Last activity: Sep 6, 2024, 09:51 AM
4 votes
1 answers
1001 views
Top forest view with filter, can I include all children?
If I'm using top in "forest" mode (V) and I restrict by PID (o PID=12345), can I also get top to show all the child processes in the same view? Ubuntu, top from procps-ng version 3.3.9
If I'm using top in "forest" mode (V) and I restrict by PID (o PID=12345), can I also get top to show all the child processes in the same view? Ubuntu, top from procps-ng version 3.3.9
dpb (145 rep)
Aug 14, 2014, 04:24 PM • Last activity: Sep 5, 2024, 08:41 AM
1 votes
0 answers
614 views
How to show all users processes using `top -m` command in Alpine Docker container?
I want to watching the processes RSS in alpine container, so I using `top -m` switch show memory mode. But it shown processes that is current user, not all users processes. Is this behavior by design or a bug? I know the `ps` command can achieve my goal, but I'm just curious about this behavior of b...
I want to watching the processes RSS in alpine container, so I using top -m switch show memory mode. But it shown processes that is current user, not all users processes. Is this behavior by design or a bug? I know the ps command can achieve my goal, but I'm just curious about this behavior of busybox command top -m.
# 1. start container
docker run -it --rm --name top_cmd alpine:3.19.3 /bin/sh
# and run top -m in this container
top -m

# 2. attach top_cmd container using other user like guest
docker exec -it -uguest top_cmd /bin/sh
# and run top -m in this container at same time
top -m

# 3. run ps command in this container at same time
docker exec -it top_cmd ps
# output
PID   USER     TIME  COMMAND
    1 root      0:00 /bin/sh    ### first step process
   16 root      0:00 top -m     ### first step process
   18 guest     0:00 /bin/sh    ### second step process
   24 guest     0:00 top -m     ### second step process
   25 root      0:00 ps

# watch this 1 and 2 step top command output, 
# they are only showing current user processes, even root.
This question might require a lot of research, so I thank the responder in advance.
eshizhan (611 rep)
Aug 17, 2024, 11:02 AM • Last activity: Aug 17, 2024, 02:36 PM
Showing page 1 of 20 total questions