Linux Check Ram Speed and Type Commands

Originally published at: https://www.cyberciti.biz/faq/check-ram-speed-linux/

How do I check RAM speed and type (line DDR or DDR2 or DDR3 or DDR4) without opening my computer? I need to purchase RAM and I need to know the exact speed and type installed. How do I find out ram information from a shell prompt? How can I check ram speed in Linux?

sudo dmidecode |grep -i “Type: DDR” |sort |uniq -c