How to Check Physical CPU Cores and Memory on a Linux Server

How to Check Physical CPU Cores and Memory on a Linux Server

When sizing hardware for solutions like Tableau Server in a Linux environment, you must determine the actual "physical" core count and total memory. Here are the quick terminal commands to check these specifications.


1. Check Physical Core Count

lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l

Tableau Server’s hardware requirements are based on "physical" cores, ignoring hyperthreading. This command filters out logical threads and returns only the exact number of physical cores.

  • lscpu -p: Prints CPU architecture information in a parsable format.
  • egrep -v '^#': Removes comment lines starting with #.
  • sort -u -t, -k 2,4: Uses a comma (,) as a delimiter and sorts by the 2nd (Core) and 4th (Socket) fields to filter out hyperthreading duplicates.
  • wc -l: Counts the total number of filtered lines.

2. Check Total Memory (RAM)

free -g | awk '/^Mem:/ {print $2}'

This command checks the total allocated physical memory in Gigabytes (GB). It extracts only the total memory value instead of displaying the full complex system output.

  • free -g: Displays the amount of memory in GB.
  • awk '/^Mem:/ {print $2}': Finds the line starting with 'Mem:' and prints only the total value located in the second column.