Macos – How to show SSD and RAM size using terminal

macosterminal

I'm a Mac Admin and was wondering if there is a quicker way to show the RAM and SSD sizes from terminal rather than running system_profiler, waiting for it to show the information, and then searching for it.

Anything would help. I know system_profiler SPHardwareDataType shows the RAM and other information, but wondering if anyone knows a command that would just show SSD and RAM information.

Thanks in advance for the help.

Best Answer

Memory size can be found with the command sysctl hw.memsize

You can convert this to a more human readable number if you need to:

hwmemsize=$(sysctl -n hw.memsize)
# 1024**3 = GB
ramsize=$(expr $hwmemsize / $((1024**3)))
echo "System Memory: ${ramsize} GB"

Volume size can be found with a short command like df -hl

Note: this does not differentiate between a HDD, SSD, or a Fusion drive. It will list any locally mounted volume.

Related Question