When managing Linux systems, especially across different hardware platforms, it's often essential to know the CPU architecture of the machine. Whether you're compiling software, troubleshooting hardware compatibility, or deploying container images, this information could be important. This tutorial explains how to get CPU architecture on Linux.
1. uname command
The uname
command is a quick way to display basic system information. To check the CPU architecture, run:
uname -m
Example output:
x86_64
Other common outputs include: aarch64
(64-bit ARM), armv7l
(32-bit ARM).
2. hostnamectl command
The hostnamectl
command is primarily used to get or set the system hostname, but it also provides detailed system information, including the CPU architecture.
hostnamectl
Example output:
Static hostname: ubuntu
Icon name: computer-desktop
Chassis: desktop
Machine ID: 75bdb67c4bf94a7c6a3d9a86d38d9e56
Boot ID: e636dbbccbd1ad589b9f9105c1c81a17
Operating System: Ubuntu 24.04.2 LTS
Kernel: Linux 6.11.0-26-generic
Architecture: x86-64
Hardware Vendor: Micro-Star International Co., Ltd.
Hardware Model: MS-7D86
Firmware Version: 1.E0
Firmware Date: Thu 2025-04-17
Firmware Age: 1month 1w 2d
To extract just the architecture line from the output:
hostnamectl | grep -Po "Architecture: \K.+"
Leave a Comment
Cancel reply