Main Menu

Search

Showing posts with label Memory utilization. Show all posts
Showing posts with label Memory utilization. Show all posts

LINUX: "ps" Command To List and Sort All Non Root User Processes By Total Memory Usage - In Descending Order PID's with Highest Total Memory Used At the Top (How To Doc)

Below "ps" command can be used to list and sort all non root user processes by total memory usage. Below command shows PID's with Highest total used Memory (in MB) owned by root user at the top and list goes down in descending order sorted by total memory usage.
ps -N -U root -wo rss=,user,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

Below is example output of above command.

# ps -N -U root -wo rss=,user,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done | more
0MB -
5959MB - oracle ora_dbw0_db
2710MB - appuser java
1957MB - oracle ora_mman_db
1156MB - orauser mysqld
853MB - oracle ora_cjq0_db
488MB - appuser java
467MB - orauser ora_mmon_db
441MB - orauser ora_smon_db
354MB - orauser ora_ckpt_db

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List and Sort ROOT User Processes By Total Memory Usage - In Descending Order PID's with Highest Total Memory Used At the Top (How To Doc)

Below "ps" command can be used to list and sort processes of root user by total memory usage. Below command shows PID's with Highest total used Memory (in MB) owned by root user at the top and list goes down in descending order sorted by total memory usage.
ps -U root -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

Below is example output of above command.

# ps -U root -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done | more
4495MB - java
34MB - OSWatcher.sh
33MB - OSWatcher.sh
32MB - OSWatcher.sh
10MB - python

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List and Sort Particular User Processes (Application Process) By Total Memory Usage - In Descending Order PID's with Highest Total Memory Used At the Top (How To Doc)

Below "ps" command can be used to list and sort processes of particular user by total memory usage. Below command shows PID's with Highest total used Memory (in MB) owned by particular user at the top and list goes down in descending order sorted by total memory usage.
ps -U <user> -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

In above command replace <user> with the username for which you want to list the processes sorted by total memory usage. 


For example if you want to list the the processes for "appuser" sorted by total memory usage, your command looks as follows:
ps -U appuser -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done

Below is example output of above command.

# ps -U appuser -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB -" $comm; done
5957MB - ora_dbw0_elctrl
2710MB - java
1957MB - ora_mman_elctrl
1157MB - mysqld
852MB - ora_cjq0_elctrl
488MB - java
467MB - ora_mmon_elctrl


Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List and Sort Processes By Memory Usage - In Descending Order PID's with Highest Memory At the Top (How To Doc)

Below "ps" command can be used to list and sort processes by Memory usage / utilization. Below commands shows PID's with Highest Memory At the Top and list goes down in descending order sorted by memory usage.
ps aux --sort -rss

Below is example output of above command.

# ps aux --sort -rss
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
oracle    6436  0.0 18.5 10347256 6100908 ?    Ss   Sep10  13:07 ora_dbw0_db
root      8340  1.2 13.9 15710044 4604788 ?    Ssl  Sep10 402:07 /usr/java/jdk1.8.0_202-amd64/bin/java -Xms200M -Xmx8192M -server -XX:StringTableSize=2
oracle    6731 44.9  8.4 11729400 2776024 ?    Sl   Sep10 14584:50 /u01/app/oracle/java/bin/java -server -Xms512m -Xmx4096m -XX:MaxPermSize=512m -Dwebl
oracle    6412  0.0  6.0 10331576 2004148 ?    Ss   Sep10   0:29 ora_mman_db

Products to which Article Applies

All Linux Operating Systems

Linux: How To Check Free Memory, Total & Used Memory on Linux Machines? ("free", "top", "vmstat", "/proc/meminfo" commands)

Below 4 commands can be used to check Free Memory, Total & Used Memory on Linux Machines.

free
top -n 1 -b | egrep "Mem|Swap"
vmstat -s | grep -i memory
 cat /proc/meminfo | egrep "Mem|Cache|Swap"

Below are sample outputs of above commands.


# free


              total        used        free      shared  buff/cache   available
Mem:        3780272     1347692     2158304        8708      274276     1584088
Swap:       4194300           0     4194300

# top -n 1 -b | egrep "Mem|Swap"


KiB Mem :  3780272 total,  2157760 free,  1348236 used,   274276 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  1583544 avail Mem

# vmstat -s | grep -i memory


      3780272 K total memory
      1347820 K used memory
       137472 K active memory
        49832 K inactive memory
      2158168 K free memory
         4172 K buffer memory

# cat /proc/meminfo | egrep "Mem|Cache|Swap"


 MemTotal:        3780272 kB
MemFree:         2158168 kB
MemAvailable:    1583992 kB
Cached:            87324 kB
SwapCached:            0 kB
SwapTotal:       4194300 kB
SwapFree:        4194300 kB


Products to which Article Applies

All Linux environments

Additional References


https://www.binarytides.com/linux-command-check-memory-usage/


https://www.linux.com/tutorials/5-commands-checking-memory-usage-linux/

LINUX: DMIDECODE Command To Check Total Memory on Linux Machine

Below dmidecode command can be used to check the total memory on the Linux Machine.

dmidecode -t memory | grep -i size | grep MB


Below is example snippet of above command.


# dmidecode -t memory | grep -i size | grep MB
        Size: 5120 MB

Products to which Article Applies


All Linux Environments

Additional References
https://www.linuxtechi.com/dmidecode-command-examples-linux/