Main Menu

Search

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

LINUX: "ps" Command To List Cumulative Used Memory In GB For All Processes Owned By All NON ROOT Users On Linux (How To Doc)

Below "ps" Command can be used to list cumulative used Memory in GB for all non root users on Linux Hosts.
ps -N -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done

Below is example output of above command which shows cumulative used memory for all non root users in GB.
ps -N -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done
21 GB

Products to which Article Applies

All Linux Operating Systems

LINUX: "ps" Command To List Cumulative Used Memory In GB For All Processes Owned By ROOT User On Linux (How To Doc)

Below "ps" Command can be used to list cumulative used Memory in GB for root user on Linux Hosts.
ps -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done

Below is example output of above command which shows cumulative used memory for root user in GB.

# ps -U root --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))" GB"; done
4 GB


Products to which Article Applies

All Linux Operating Systems


LINUX: "ps" Command To List Cumulative Used Memory In GB For All Processes Owned By Particular User On Linux (How To Doc)

Below "ps" Command can be used to list cumulative used Memory in GB for all processes owned by particular user on Linux Hosts.
ps -U <user> --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))"GB"; done

In above command replace <user> with the user for which you want to find cumulative used memory of all the processes. Below is example output of above command which shows cumulative used memory for appuser in GB. 

# ps -U oracle --no-headers  -o rss | (tr '\n' +; echo 0) | bc | while read -r rss; do echo $((rss/1024/1024))" GB"; done
20 GB


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/