Setting Up NASM and Linking on Linux

Rawley AmankwahRawley Amankwah
2 min read

Assembly programming on Linux requires two key tools:

  • NASM (Netwide Assembler) for compiling .asm source files.

  • A linker (usually ld from binutils or gcc for simplicity) to produce executables.

Here’s how to set them up across various Linux distributions:


🐧 Ubuntu / Debian-based Systems

sudo apt update
sudo apt install binutils  # For installing the ld linker (Recommended)
sudo apt install nasm gcc  # gcc is also a linker

✔️ nasm: the assembler
✔️ gcc: used as linker (you can use ld too: sudo apt install binutils)

🐧 Fedora

sudo dnf install nasm gcc

✔️ Fedora handles packages cleanly. nasm and gcc are available in the default repos.

🐧 Arch Linux / Manjaro

sudo pacman -S nasm gcc

✔️ Pacman keeps it lean and fast. Everything you need is in the official repositories.

🐧 openSUSE

sudo zypper install nasm gcc

✔️ Zypper delivers both NASM and the GNU toolchain out of the box.

✅ Verifying the Installation

Run:

nasm -v
gcc --version 
ld -v         # Recommended

You should see version info confirming successful installs.

When writing NASM x64 code, choose a text editor that gets out of your way and lets you focus on the bytes:

  1. Nano (Recommended) : Simple, no-nonsense, and pre-installed on most Linux systems. Great for beginners.

  2. Vim: Comes pre-installed in all Linux distributions. Powerful, efficient, and universally available. Steep learning curve, but worth it if you’re serious.

  3. Micro: A modern terminal-based editor that lies between Nano and Vim. One can use the following command in Ubuntu: sudo apt install micro

  4. Sasm: A GUI based lightweight editor which is not pre-installed.

Writing your first “Hello World” in Nasm x64

0
Subscribe to my newsletter

Read articles from Rawley Amankwah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rawley Amankwah
Rawley Amankwah