How to Check CPU, Frequency and RAM in Debian Linux (lscpu, /proc/cpuinfo, free)

Category: Servers & Websites
Posted: February 14, 2013
Author: Antonio

I rented a Debian Linux VPS. Linux is different from FreeBSD, which I’ve worked with for a long time, so small questions keep coming up — I write them down so I know where to look. The first one: how to check the processor, its frequency and the amount of memory. All the commands below work on Debian, Ubuntu and other distributions.

How to check CPU and RAM in Debian: lscpu, nproc, free -h

The quick way: lscpu

lscpu

It shows everything important: the CPU model (Model name), the number of cores and threads (CPU(s), Core(s) per socket, Thread(s) per core), frequency, cache size and the virtualization type if it’s a VPS.

On my old VPS, lscpu returned an error:

lscpu: error: /sys filesystem is not accessable.

This happens in OpenVZ containers where /sys isn’t mounted. In that case use the method below — /proc/cpuinfo is always there.

/proc/cpuinfo

cat /proc/cpuinfo

The file lists data for every core separately, so the output is long. It’s easier to pull out just what you need:

grep -m1 'model name' /proc/cpuinfo
nproc
grep MHz /proc/cpuinfo
  • the first command shows the CPU model;
  • nproc — how many cores (threads) are available to the system;
  • the third shows the current frequency of each core in MHz.

The frequency changes with load. To watch it live (exit with Ctrl+C):

watch -n1 "grep MHz /proc/cpuinfo"

How much memory

free -h
grep MemTotal /proc/meminfo

free -h shows total, used and free memory plus swap in readable units (Gi, Mi). Look at the available column — that’s how much memory programs can actually use.

Check that your VPS matches the plan

These commands are enough to make sure your provider gave you what it promised:

nproc
free -h
df -h /
systemd-detect-virt

The last command shows the virtualization type: kvm is a full virtual machine, while openvz or lxc is a container that shares some resources with its neighbors.

Detailed hardware info

For a summary of the whole machine at once, install inxi:

sudo apt install inxi
inxi -C
inxi -F

inxi -C gives details about the CPU, and inxi -F about the whole system: CPU, memory, disks, network and graphics.

In short

CPU — lscpu or grep -m1 'model name' /proc/cpuinfo, cores — nproc, frequency — grep MHz /proc/cpuinfo, memory — free -h.

Need a VPS to practice on? On Vultr you can spin up a Debian server in one of 30+ locations with hourly billing and delete it when you’re done, so a quick test costs only a few cents.

The Vultr link is an affiliate link: it costs you nothing extra, and the blog gets a small reward.

Related posts:

Leave a Comment

Copying content from this site is allowed only with a direct link to the source - https://nemcd.com