Linux: How to compile program

Many newbies find it difficult to compiling programs under Linux (command mentioned below should also work with FreeBSD or any other UNIX like system). The fact that Linux is open source OS, so most of the programs are also open sources. Improvements and security, bug patches needs to us compile not just Kernel but softwares/programs. Please note that you can download program with wget and extract the file with tar command.

If file extensions is .gz then use tar command as follows to extract tar ball:
$ tar -zxvf file.tar.gz

If file extensions is .bz2 then use tar command as follows to extract tar ball:
$ tar -jxvf file.tar.bz2

Three common steps to compiling program under Linux:

Step # 1: Configure (read as prepare) the program for compile on your system/architecture.

Generally configure command is used:
$ ./configure

Step # 2: Compiling the program
Use make command to compiling program:
$ make

Step # 3: Install the program
First become a root user:
$ su -


Next install the software with following command:
# make install

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • Daiphyer Dec 11, 2007 @ 10:45

    If file extensions is .bz2 then use tar command as follows to extract tar ball:
    $ tar -jxvf file.tar.gz

    I am guessing it should be .bz2 insteat of .tar.gz

  • 🐧 nixCraft Dec 11, 2007 @ 11:32

    thanks for the heads up!

  • frog Dec 9, 2008 @ 16:48

    ok so im a newb and i get all these in every thing i d l but no one tells you where to open file to is it xmacs emacks tmacks rpm ark yast come on don’t be so veg i need some real help all i have is a tar. file i open it yes i see a read me file and a config make and source files but what do i open them in to my guess is emacs but no explanation to what ive playd w/ it for hours i tryd to open w/ icecream rpm yast emacs ark tem shell tried bash ash o god some one put it in lamen terms wright a book and u will make millions to much i find on the net linux/unix/os users try ro make it sound to hard for an average user to do

  • mallikarjun Dec 15, 2008 @ 5:48


    i geting permission deny error while compiling module programme, and also enter through super user sometime it will disply module librery undefined pls help me

  • guru Feb 3, 2009 @ 1:34

    How to add a user written device driver to the kernel

  • raj Feb 22, 2010 @ 4:37

    nIs it possible to compile a program in one version of linux and use it in any other version?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum