arch

system informationlinux
The arch command is one of the most frequently used commands in Linux/Unix-like operating systems. arch The arch command displays the machine architecture name of the current system. It is a simple command that prints the hardware name in a standard format.

Quick Reference

Command Name:

arch

Category:

system information

Platform:

linux

Basic Usage:

arch [options] [arguments]

Common Use Cases

  • 1

    System information gathering

    Quickly identify the hardware architecture of the current system

  • 2

    Installation scripts

    Determine which binary packages to install based on the architecture

  • 3

    Cross-platform development

    Verify system architecture for software compatibility

  • 4

    Containerization

    Check architecture compatibility in container environments

Syntax

arch

Options

Option Description
--help Display a help message and exit
--version Output version information and exit

Examples

How to Use These Examples

The examples below show common ways to use the arch command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

#

Basic Examples:

# Display the machine architecture
arch
# Use with other commands echo "System architecture: $(arch)"
# Check architecture for conditional operations if [ "$(arch)" = "x86_64" ]; then echo "This is a 64-bit system" else echo "This is not a 64-bit system" fi

Advanced Examples:

# Compare with similar commands
arch
uname -m
dpkg --print-architecture  # Debian/Ubuntu
rpm --eval "%{_arch}"     # Red Hat/Fedora
# Use in scripts to determine compatible software case $(arch) in x86_64) echo "Installing 64-bit version..." ;; i*86) echo "Installing 32-bit version..." ;; aarch64) echo "Installing ARM 64-bit version..." ;; *) echo "Unsupported architecture: $(arch)" exit 1 ;; esac
# Verify expected architecture in installation scripts if [ "$(arch)" != "x86_64" ]; then echo "Error: This software requires a 64-bit (x86_64) system" exit 1 fi
# Use in Docker or container environments to check the host architecture docker run --rm alpine arch

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Command Description:

The arch command prints the machine hardware name, showing the basic architecture of the current system. It's a simple utility that returns a standardized architecture name without any options or arguments.

Common Architecture Names:

  • x86_64 or amd64: 64-bit x86 architecture (most common for modern PCs and servers)
  • i386, i486, i586, i686: 32-bit x86 architectures
  • aarch64 or arm64: 64-bit ARM architecture (used in many mobile devices and newer servers)
  • armv7l, armv6l: 32-bit ARM architectures
  • ppc64le: 64-bit PowerPC architecture (little-endian)
  • ppc64: 64-bit PowerPC architecture (big-endian)
  • s390x: IBM System z architecture
  • mips, mips64: MIPS architectures
  • riscv64: 64-bit RISC-V architecture

Compatibility and Alternatives:

The arch command is similar to uname -m and they often provide the same output. There are several related commands that provide architecture information:

  • uname -m: Prints the machine hardware name
  • uname -p: Prints the processor type
  • uname -i: Prints the hardware platform
  • dpkg --print-architecture: On Debian-based systems, shows the system architecture
  • rpm --eval "%{_arch}": On RPM-based systems, shows the system architecture
  • getconf LONG_BIT: Shows if the system is 32-bit or 64-bit

Use Cases:

  • Installation scripts: Determine the appropriate binaries to install based on system architecture
  • Compatibility checks: Verify if software is compatible with the current system
  • Build systems: Set architecture-specific compilation flags
  • System information: Simple way to check the hardware architecture
  • Containerization: Verify the architecture in container environments

Interpretation of Output:

The output of the arch command is a single string representing the machine architecture:

  • A value of x86_64 indicates a 64-bit Intel/AMD system
  • Values like i686 indicate 32-bit Intel systems
  • Values like aarch64 indicate 64-bit ARM systems

Historical Context:

The arch command has been available in Unix-like systems for decades. It's a simple command that comes from the GNU coreutils package. In modern Linux distributions, it's sometimes included as part of the util-linux package rather than coreutils.

Important Notes:

  • The arch command provides the hardware architecture, not the operating system architecture
  • On systems with compatibility layers (like 64-bit systems that can run 32-bit applications), arch still shows the native hardware architecture
  • For scripts that need to work across different systems, it's often better to use uname -m as it's more universally available
  • The command has no additional options or arguments beyond standard help and version flags
  • On some systems, arch may be a symbolic link to uname

Tips & Tricks

1

Use the -i option to display the machine hardware name

2

Use the -m option to display the machine hardware platform

3

Use the -o option to display the operating system name

4

Use the -v option to display the version information

5

Use the -a option to display all available architecture information

Common Use Cases

System information gathering

Quickly identify the hardware architecture of the current system

Installation scripts

Determine which binary packages to install based on the architecture

Cross-platform development

Verify system architecture for software compatibility

Containerization

Check architecture compatibility in container environments

Conditional execution

Run architecture-specific commands or optimizations in scripts

Related Commands

These commands are frequently used alongside arch or serve similar purposes:

Use Cases

1

System information gathering

Quickly identify the hardware architecture of the current system

2

Installation scripts

Determine which binary packages to install based on the architecture

3

Cross-platform development

Verify system architecture for software compatibility

4

Containerization

Check architecture compatibility in container environments

5

Conditional execution

Run architecture-specific commands or optimizations in scripts

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the arch command works in different scenarios.

$ arch
View All Commands