Monday, October 17, 2016

See Which Processes are Consuming Most of Your Physical Memory/RAM on Linux

To view the processes that are using your RAM use the following command,

sudo ps aux | awk '{print $2 " " $6}' | sort -k2,2 -nr | grep -v 0 | grep -v RSS
1963 82432
2928 39884
3634 32112
3253 28792
2868 28764
3247 27952
3255 27524
3257 18116
2994 15688
2867 14196
1769 13988
1883 12744
2827 9656
1762 8228
2775 8116
2784 7232
2797 6436
3225 6424
1 5676
3354 5484
617 5184
3217 5112
3287 4884
1645 4836
2525 4296
3976 3984
3977 3384
1731 3332
571 3272
1766 3196
1738 2988
2869 2984
1997 2484
2251 1864
2496 1832
1761 1276
3979 936
1771 856
3978 768
2547 316

The first column is the PID(process ID) and the second column is the amount of RAM(in kilobytes) used by that process.



If you want to view the top 5 process from that big list, you can use the following command,

sudo ps aux | awk '{print $2 " " $6}' | sort -k2,2 -nr | grep -v 0 | grep -v RSS | head -n 5
1963 82432
2928 39884
3634 32112
3253 28792
2868 28764

Here 1963 is the PID(process ID) and it is using 82432KB of the physical memory(RAM).



If you want to know more about the process, you can use the PID like this,

sudo ps p 1963
 PID TTY      STAT   TIME COMMAND
1963 tty7     Ss+    0:37 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0

Here 1963 is the PID of the process.

No comments:

Post a Comment