Skip to main content
ZhimaYuandi
← Back to blog
#Linux#Command Line#System Resources

Linux Resource Commands: OS, Memory, CPU and Disk

Check Linux OS details, total memory, available CPU processing units and disk capacity, with a combined command, sample output and metric definitions.

5 min

On Linux systems with /proc, /etc/os-release, GNU coreutils and util-linux, the command below summarizes the OS, memory, available CPU processing units and block-device capacity. Use it for a server inventory. It reports resources visible to the current environment, rather than measuring performance or exporting an Excel file.

echo "System name: $(grep PRETTY_NAME /etc/os-release | cut -d'=' -f2 | tr -d '"')" && \
echo "Total memory: $(awk '/MemTotal/ {printf "%.2f GiB\n", $2/1024/1024}' /proc/meminfo)" && \
echo "Available CPU processing units: $(nproc)" && \
echo "Total disk: $(lsblk -b -d -o SIZE,TYPE | awk '$2=="disk"{sum+=$1} END{printf "%.2f GiB\n", sum/1024/1024/1024}')"

The output looks like this:

System name: CentOS Linux 7 (Core)
Total memory: 125.39 GiB
Available CPU processing units: 96
Total disk: 3312.49 GiB

What the numbers mean

  • MemTotal is the total usable RAM reported by the kernel, not currently free RAM. Use free -h to inspect current usage.
  • nproc reports processing units available to the current process, not physical CPU sockets or physical cores.
  • Disk capacity sums visible block devices whose TYPE is disk. It is not free filesystem space; use df -h for mounted filesystem usage.
  • These calculations use powers of 1024, so the unit is GiB. Containers, virtual machines and permission limits can affect the visible resources; record the environment alongside an inventory.

References: GNU nproc manual, Linux kernel /proc documentation.