How to check if the system is 32-bit or 64-bit in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to determine if your Linux system is 32-bit or 64-bit. You will explore different command-line tools commonly used for this purpose, including uname -m and arch.

Through hands-on practice, you will execute these commands in the terminal and interpret their output to identify the system's architecture. You will also learn how to inspect binary files like /bin/ls to gain further insight into the system type. This lab will equip you with essential skills for understanding your Linux environment and ensuring software compatibility.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/SystemInformationandMonitoringGroup(["System Information and Monitoring"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicSystemCommandsGroup -.-> linux/man("Manual Access") linux/SystemInformationandMonitoringGroup -.-> linux/uname("System Information Displaying") subgraph Lab Skills linux/help -.-> lab-558809{{"How to check if the system is 32-bit or 64-bit in Linux"}} linux/man -.-> lab-558809{{"How to check if the system is 32-bit or 64-bit in Linux"}} linux/uname -.-> lab-558809{{"How to check if the system is 32-bit or 64-bit in Linux"}} end

Check architecture with uname -m

In this step, you'll learn how to check your system's architecture using the uname command. Understanding your system's architecture is important for installing the correct software and understanding how your system works.

The uname command is used to print system information. When used with the -m option, it prints the machine hardware name (architecture).

Open your terminal if it's not already open. You can find the Xfce Terminal icon on the left side of your desktop.

Now, type the following command into the terminal and press Enter:

uname -m

You should see output similar to this:

x86_64

This output indicates that your system is running on an x86_64 architecture, which is a common 64-bit architecture used in most modern computers.

Illustration for uname -m command

The uname command has other useful options as well. For example, uname -a will print all system information. Feel free to experiment with uname -a in your terminal to see more details about your system.

Remember, the LabEx environment is a safe place to practice and explore. Don't hesitate to try out commands and see what they do!

Click Continue to proceed to the next step.

Verify system type with arch command

In this step, you'll use the arch command to verify the system's architecture. The arch command is another way to display the machine's architecture, often providing the same output as uname -m.

Using different commands that provide similar information is a common practice in Linux. It's good to be familiar with multiple tools for the same task.

Make sure your terminal is open. Type the following command and press Enter:

arch

You should see output similar to what you saw with uname -m:

x86_64

This confirms that the system architecture is indeed x86_64.

Illustration for arch command step

While uname -m and arch often give the same result, uname is a more versatile command with many options for displaying different system information. arch is specifically designed to show the architecture.

Continue practicing by typing the command yourself in the terminal. This hands-on approach is key to learning Linux effectively.

Click Continue to move on to the next step.

Inspect binary with file /bin/ls

In this step, you'll use the file command to inspect the /bin/ls binary. The file command is a powerful utility that determines the type of a file. It can identify various file types, including executable binaries, scripts, text files, and more.

/bin/ls is the executable file for the ls command, which you'll use frequently in Linux to list directory contents. It's located in the /bin directory, which typically contains essential user command binaries.

Open your terminal. Type the following command and press Enter:

file /bin/ls

You should see output similar to this:

/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=36b86f957a1be53733633d184c3a3354f3fc7b12, for GNU/Linux 3.2.0, stripped
Output of file /bin/ls command

Let's break down some of this output:

  • ELF 64-bit LSB executable: This tells us that /bin/ls is an Executable and Linkable Format (ELF) file, which is the standard binary format on Linux. It's a 64-bit executable and uses Little-Endian byte ordering (LSB).
  • x86-64: This confirms the architecture of the binary matches the system architecture we found in the previous steps.
  • dynamically linked: This means the executable relies on shared libraries (like .so files) at runtime.

The file command is incredibly useful for understanding what kind of data a file contains, especially when the file extension is missing or misleading.

Practice using the file command on other files you might find in the system, like /bin/bash or /usr/bin/htop (if you installed it in a previous lab).

Click Continue to complete this step and the lab.

Summary

In this lab, you learned how to determine if a Linux system is 32-bit or 64-bit using two common commands. You first used uname -m to display the machine hardware name, which typically indicates the architecture (e.g., x86_64 for 64-bit). You then verified this information using the arch command, which also outputs the system architecture. These steps demonstrated simple yet effective ways to check this fundamental system property in Linux.