To check a binary's architecture, you inspect the file's format metadata to determine its instruction set, bit width, and byte order, then verify running processes against it when needed. The fastest single command is file, which reads executable headers and reports results like "ELF 64-bit LSB pie executable, x86-64." On Linux, readelf, objdump, and uname confirm the details; on macOS, file, lipo -info, and otool cover thin and universal binaries; on Windows, PowerShell, dumpbin, and Sysinternals tools handle PE files. Success means the reported machine type, bit width, and endianness match what you expect before loading or deploying the binary.

This guide walks through each platform in a workable order, explains what the output actually means, and covers the ambiguous cases — scripts, universal binaries, containers, and files that merely look like executables. A quick note on scope: the exact output wording differs by tool version, so treat the examples as patterns to match, not guaranteed strings.

Start with the file command and read what it tells you

The file utility is the closest thing to a universal first check because it examines magic numbers and header fields rather than trusting the file extension. Run:

Typical results include:

ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked — a 64-bit Linux x86-64 program, little-endian. ELF 32-bit MSB executable, PowerPC or cisco 4500 — big-endian 32-bit. MSB means most significant byte first; LSB means least significant byte first. Mach-O 64-bit executable arm64 — a 64-bit macOS Apple Silicon or universal component. PE32+ executable (console) x86-64, for MS Windows — a 64-bit Windows program. PE32 executable (GUI) Intel 80386, for MS Windows — a 32-bit Windows GUI program.

Three fields matter most. The bit width (32 versus 64) tells you the pointer size and address range the program was compiled for. The endianness (LSB/MSB) matters if you're parsing data across platforms. The machine type (x86-64, arm64, aarch64, MIPS, RISC-V) determines which instruction set the CPU must implement. Everything else — linking style, stripping, kernel version markers — is secondary context.

A caveat: file uses heuristics on some formats, so on unusual or obfuscated files it may say "data" or guess wrong. When that happens, fall through to the format-specific tools below.

Checking ELF binaries on Linux

Linux executables are almost always ELF, and the ELF header contains a fixed e_machine field plus an EI_CLASS byte for bit width. file reads both, but readelf and objdump give you the raw values and much more.

Run:

The header output includes Class: ELF64 (or ELF32), Data: 2's complement, little endian (or big endian), Machine: Advanced Micro Devices X86-64, Type: DYN (position-independent executable) or EXEC, and the entry point. If you only want the machine architecture line, objdump -f ./myprogram shows architecture: i386:x86-64 and file format: elf64-x86-64.

Two practical distinctions to keep straight:

Bit width versus instruction set. A 64-bit ARM binary (ELF64, Machine: AArch64) will not run on x86-64 hardware at all, so the bit width alone is not enough — you need the machine type. Conversely, a 32-bit x86 binary can sometimes run on a 64-bit x86-64 kernel, but only if the compatibility libraries are installed. Dynamically linked versus static. The Type and the presence of .interp tell you whether the binary expects a dynamic loader. That does not change the architecture, but it does affect whether the binary runs on a minimal system.

If you want the machine type without parsing text, readelf -h combined with grep Machine is a reliable scripted check. Success looks like a Machine: line that names the expected CPU and a Class: line matching your deployment target.

To check the running side rather than the file side, use uname -m (kernel architecture, e.g. x86_64 or aarch64), getconf LONG_BIT (userspace bit width), and ps -e -o pid,comm,args combined with file /proc//exe to see what a specific process was built as.

Handling macOS thin, universal, and stale binaries

macOS uses Mach-O and adds a wrinkle: a file can contain more than one architecture. Debug builds and distribution apps are often "universal" (formerly "fat") — a single file with x86_64 and arm64 slices, letting the same app run on Intel and Apple Silicon Macs.

Check with:

file reports the first slice and usually notes that the file is universal. lipo -info lists every architecture, for example Architectures in the fat file: ./myapp are: x86_64 arm64. To inspect one slice, use lipo -thin arm64 ./myapp -output ./myapp-arm64 (this writes a new file rather than modifying the original), then run file on the extracted slice.

otool -l ./myapp shows load commands including the LC_BUILD_VERSION and the CPU type; otool -hv prints the Mach header. One important caveat: Apple's translation layer, Rosetta 2, lets x86_64 binaries run on Apple Silicon. So a program may execute successfully on an arm64 Mac while being an Intel binary. If your goal is native performance or forward compatibility, verify the architecture rather than trusting that it launched. And gatekeeper/quarantine attributes can affect whether a downloaded binary runs at all, which is a separate concern from architecture.

Checking Windows PE files

Windows executables and DLLs are PE format. The header carries a Machine field and a PE32/PE32+ marker: PE32 corresponds to 32-bit (x86) images, and PE32+ to 64-bit (x86-64 or ARM64). That naming trips people up — PE32+ does not mean "more 32-bit," it means the 64-bit variant.

The file utility from Git for Windows or MSYS2 reports it directly, as shown earlier. Inside a normal Windows install, PowerShell can read the header:

The machine value 014C is x86, 8664 is x86-64, and AA64 is ARM64. This is a small script but it demonstrates the principle: architecture lives in a fixed header field, so you can read it without executing the binary.

For visual and bulk inspection, Sysinternals' sigcheck -a prints the machine type alongside version and signature data, and the Developer Command Prompt's dumpbin /headers app.exe shows machine (x64) or (x86) in the file header section. dumpbin is available with Visual Studio build tools, not on stock Windows. For tasks and services, Task Manager's Details tab shows platform per running process, which helps correlate files with what's actually running.

One edge case for Windows: a 32-bit process on 64-bit Windows may appear under C:\Windows\SysWOW64, and "WOW64" in that path means "Windows 32-bit on Windows 64-bit". So the directory name is a warning, not a typo.

Containers, cross-compiled output, and architecture in pipelines

In Docker and Kubernetes, architecture often diverges from the host. docker image inspect --format '{{.Architecture}}' prints amd64, arm64, arm/v7, and similar values; docker manifest inspect shows the architectures the tag resolves to across the manifest list. Inside a running container, file /bin/sh (or any real binary) and uname -m on the running kernel tell you what the container was built as and what it's executing on. Multi-arch images exist precisely because a single tag can map to several architectures: if you pull on an arm64 machine and the image has no arm64 slice, Docker either falls back or fails depending on the platform settings.

For cross-compiled output, the confusion is that the build machine and the target machine differ. GOARCH and GOOS in Go, -target in Rust, and -arch in Clang all control output architecture, but the resulting binary tells the truth. A common failure mode is testing a binary on the build host and assuming the deployment host matches — verify the artifact that ships, not the one you compiled. In CI, a one-line gate prevents the mistake: file ./artifact | grep -q 'x86-64' or a loose check on the Machine: field, with a deliberate failure when the string is absent. Make the expected architecture and bit width explicit inputs to the check rather than matching a hardcoded string, so the same pipeline serves multiple targets.

A second pipeline hazard is confusing an unpacked installer or a self-extracting archive with the program itself. Those files are executables with their own architecture and runtime behavior; the payload they deliver may differ. If file reports a script or a generic data blob where you expected a machine type, check whether you're inspecting a wrapper before concluding the tool chain broke.

Byte order, bit width, and instruction set are different questions

Many "wrong architecture" mysteries come from conflating three independent properties:

Instruction set (machine type). The CPU vocabulary: x86-64, AArch64/ARM64, RISC-V, MIPS, PowerPC. This is the most fundamental compatibility constraint — a mismatch guarantees the program cannot execute natively. Bit width. Pointer size, addressable memory, and how arguments pass in registers. A 32-bit binary on a 64-bit kernel may or may not run depending on the OS and installed libraries; 64-bit binaries cannot run on a 32-bit kernel at all. Endianness. The order multi-byte values are stored. This is usually invisible in everyday use, but it's the first thing to check when a binary behaves oddly with network or binary-file data on a big-endian platform (PowerPC, MIPS in BE mode, and some embedded systems).

Another frequently confused pair is architecture versus ABI: the CPU model is one thing, but calling conventions, C library, and object format (ELF versus Mach-O versus PE) determine whether a binary is compatible with a given system even when the machine type matches. A Linux arm64 binary won't run on macOS arm64, and vice versa. So when someone asks "what architecture is this binary," the useable answer for compatibility includes the OS and format context, not just the instruction set. The bit width and endianness are properties of that same header; they don't replace the machine type.

Troubleshooting common verification failures

Symptom: file says "data" or "ASCII text." Likely causes: the file is a shell or Python script, an archive, a compressed stream, or a binary that was altered/concatenated. Check the shebang line for scripts; xxd | head for magic bytes (7F 45 4C 46 for ELF, 4D 5A for PE, CA FE BA BE for Mach-O). Reversible first step: confirm you're inspecting the artifact you intended, not a wrapper or a partial download. If it's a legitimately unknown format, stop guessing and get the author's format documentation.

Symptom: the binary reports x86-64 but "isn't supported on this CPU." Check uname -m on the target; you may be on arm64. Rosetta/QEMU emulation can mask this. Confirm the running process actually matches the file: file /proc//exe on Linux. Stop condition: if an emulator is involved and you're seeing crashes or performance anomalies, that's a platform-integration investigation rather than an architecture identification, and it belongs with the vendor or platform team.

Symptom: it runs, but unexpectedly. Maybe it runs under emulation, or maybe the first slice of a universal binary isn't the one the OS selected. lipo -info lists all slices; the OS chooses the native one. If the binary launches but crashes in code paths, that's a deeper compatibility/debugging problem; the architecture check has done its job.

Symptom: the check disagrees across tools. Version differences and tool-specific heuristics explain minor wording changes; substantive disagreement usually means you're looking at different files or slices. Compare with a second tool on the same path and same execution context. If the discrepancy persists and the binary is part of a production deployment, escalate to the build pipeline owner rather than editing anything in place.

The one essential rule: verify the exact artifact that will run on the exact target, in the same container or environment, because architecture metadata lives in the file, but compatibility depends on where that file lands.