Determining the amount of memory in a system running Ubuntu Linux

Learning that lasts. Online courses from $14.99

If you need to determine the amount of memory in a system that is running the Ubuntu Linux operating system (OS), you can open a Terminal window from the App Center and then use the free command. If you use the command without any options, you will see the amount of memory displayed in bytes. To display the value in a more human-friendly format, you can add the argument -h or --human, e.g., to see the value in gigabytes.

alice@firefly:~$ free -h
               total        used        free      shared  buff/cache   available
Mem:            14Gi       2.4Gi        10Gi       426Mi       2.3Gi        12Gi
Swap:          4.0Gi          0B       4.0Gi
alice@firefly:~$

Other options for the command are shown below:

jim@Serenity:~$ free --help

Usage:
 free [options]

Options:
 -b, --bytes         show output in bytes
     --kilo          show output in kilobytes
     --mega          show output in megabytes
     --giga          show output in gigabytes
     --tera          show output in terabytes
     --peta          show output in petabytes
 -k, --kibi          show output in kibibytes
 -m, --mebi          show output in mebibytes
 -g, --gibi          show output in gibibytes
     --tebi          show output in tebibytes
     --pebi          show output in pebibytes
 -h, --human         show human-readable output
     --si            use powers of 1000 not 1024
 -l, --lohi          show detailed low and high memory statistics
 -L, --line          show output on a single line
 -t, --total         show total for RAM + swap
 -v, --committed     show committed memory and commit limit
 -s N, --seconds N   repeat printing every N seconds
 -c N, --count N     repeat printing N times, then exit
 -w, --wide          wide output

     --help     display this help and exit
 -V, --version  output version information and exit

For more details see free(1).
jim@Serenity:~$ 

Note:The free command in Linux shows the total amount of installed physical memory in the total column, but this value is less than the actual hardware random-access memory (RAM) installed because the Linux kernel reserves a portion of memory for itself and for hardware devices (like video card buffers) at boot time. The total shown is the usable RAM available to the OS, not the absolute hardware total.

To view the capacity of memory modules on the system, you can use the dmicode command shown below, which will show the total amount of actual hardware RAM.

alice@firefly:~$ sudo dmidecode -t memory | grep -i size
[sudo: authenticate] Password:
	Size: 8 GB
	Size: 8 GB
alice@firefly:~$

You can also use the lshw command specifying the class "memory" as shown below to view information on the system's memory. Note: you will get much more detail if you use sudo to run the command as the superuser. In the example below, the command, when run with sudo, shows the system has one 8 GB memory module manufactured by Samsung and another 8 GB memory module manufactured by Timetec.

alice@firefly:~$ lshw -class memory
WARNING: you should run this program as super-user.
  *-memory
       description: System memory
       physical id: 0
       size: 16GiB
  *-memory UNCLAIMED
       description: Memory controller
       product: Sunrise Point-LP PMC
       vendor: Intel Corporation
       physical id: 1f.2
       bus info: pci@0000:00:1f.2
       version: 21
       width: 32 bits
       clock: 33MHz (30.3ns)
       capabilities: bus_master
       configuration: latency=0
       resources: memory:b122c000-b122ffff
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
alice@firefly:~$ sudo lshw -class memory
  *-firmware
       description: BIOS
       vendor: Insyde
       physical id: 0
       version: F.64
       date: 07/23/2021
       size: 128KiB
       capacity: 6MiB
       capabilities: pci upgrade shadowing cdboot bootselect edd int13floppynec 
int13floppytoshiba int13floppy360 int13floppy1200 int13floppy720 int13floppy2880
 int9keyboard int10video acpi usb biosbootspecification uefi
  *-cache:0
       description: L1 cache
       physical id: 5
       slot: L1 Cache
       size: 128KiB
       capacity: 128KiB
       capabilities: synchronous internal write-back unified
       configuration: level=1
  *-cache:1
       description: L2 cache
       physical id: 6
       slot: L2 Cache
       size: 512KiB
       capacity: 512KiB
       capabilities: synchronous internal write-back unified
       configuration: level=2
  *-cache:2
       description: L3 cache
       physical id: 7
       slot: L3 Cache
       size: 4MiB
       capacity: 4MiB
       capabilities: synchronous internal write-back unified
       configuration: level=3
  *-memory
       description: System Memory
       physical id: 27
       slot: System board or motherboard
       size: 16GiB
     *-bank:0
          description: SODIMM DDR4 Synchronous Unbuffered (Unregistered) 2400 MH
z (0.4 ns)
          product: M471A1K43CB1-CTD
          vendor: Samsung
          physical id: 0
          serial: 39BFFECF
          slot: Bottom-Slot 1(left)
          size: 8GiB
          width: 64 bits
          clock: 2400MHz (0.4ns)
     *-bank:1
          description: SODIMM DDR4 Synchronous Unbuffered (Unregistered) 2400 MH
z (0.4 ns)
          product: TIMETEC-S8G-2400
          vendor: 8C26
          physical id: 1
          serial: 00000000
          slot: Bottom-Slot 2(right)
          size: 8GiB
          width: 64 bits
          clock: 2400MHz (0.4ns)
  *-memory UNCLAIMED
       description: Memory controller
       product: Sunrise Point-LP PMC
       vendor: Intel Corporation
       physical id: 1f.2
       bus info: pci@0000:00:1f.2
       version: 21
       width: 32 bits
       clock: 33MHz (30.3ns)
       capabilities: bus_master
       configuration: latency=0
       resources: memory:b122c000-b122ffff
alice@firefly:~$