How to Install FASM in Linux

NOTE: This how-to was tested in Ubuntu 14.04 LTS. Other Linux distribution may employ other means, but the basic principle should be the same. So read on and make the necessary adjustment as you see fit.

  1. Download fasm for Linux.


  2. Open a terminal and switch user to root:

    $ sudo su

    when ask for a password, type in your password (normally, the one you used when you login to your system)

  3. Copy fasm-1.71.22.tgz into /opt directory (or to a directory where you want fasm to finally reside. I chose it to reside to /opt)

    # cp /<source_dir>/fasm-1.71.22.tgz /opt


  4. Extract fasm

    # tar -xzvf fasm-1.71.22.tgz

    fasm directory will be created containing the following:


    the compiler is already in binary form (although you have to option to rebuilt it from the included source code if you are more adventurous), so you can actually use it right away.

  5. Go into fasm directory and execute fasm to see if it will run

    # cd /opt/fasm
    # ./fasm

    you should see something like below:


  6. Now, include fasm directory into your path so you can execute it anywhere from your CLI (Command Line Interface). We want it to be available system-wide. Open a terminal and change user to root:

    $ sudo su
    # echo “export PATH=$PATH:/opt/fasm” >> /etc/profile


    Edit /etc/environment file and insert the path to fasm in the PATH environment variable:

    # vi /etc/environment


    After any of these changes, you need to reboot your computer for it to take effect.

    If everything works fine, you should be able to see the following when you execute fasm anywhere in your CLI:


  7. To fully test if we really have a working fasm, let’s compile the included hello.asm. Open a terminal and copy the hello example files from /opt/fasm/examples/elfexe/:$ cd ~
    $ mkdir asm
    $ cd asm
    $ cp /opt/fasm/examples/elfexe/hello.asm .
    $ cp /opt/fasm/examples/elfexe/hello64.asm . ## you can also include this if you have 64-bit computer

    Compile to create their corresponding executable files:

    $ fasm hello.asm
    $ fasm hello64.asm

    The following should be the output:


Comments on this post

  1. Thankyou for this post, I am a big fan of this site would like to go on updated.

  2. This is nice!

Leave a Reply

Your email address will not be published. Required fields are marked *

Trackbacks and Pinbacks on this post

No trackbacks.

TrackBack URL