How to build a RPM or DEB package from the source with CheckInstall

Last updated on November 6, 2020 by Dan Nanni

Question: I would like to install a software program by building it from the source. Is there a way to build and install a package from the source, instead of running make install? That way, I could uninstall the program easily later if I want to.

If you have installed a Linux program from its source by running make install, it becomes really tricky to remove it completely, unless the author of the program provides an uninstall target in the Makefile. You will have to compare the complete list of files in your system before and after installing the program from source, and manually remove all the files that were added during the installation.

That is when CheckInstall can come in handy. CheckInstall keeps track of all the files created or modified by an install command line (e.g., make install, make install_modules, etc.), and builds a standard binary package, giving you the ability to install or uninstall it with your distribution's standard package management system (e.g., yum for CentOS/RHEL or apt-get for Ubuntu/Debian). It has been also known to work with Slackware, SuSe, Mandrake and Gentoo as well, as per the official documentation.

In this post, I will only focus on Red Hat and Debian based distributions, and show how to build a RPM or DEB package from the source using CheckInstall.

Installing CheckInstall on Linux

To install CheckInstall on Ubuntu and other Debian derivatives:

# aptitude install checkinstall

To install CheckInstall on Red Hat-based distributions such as CentOS, you will need to download a pre-built RPM file of CheckInstall (e.g., searchable from, as it has been removed from the Repoforge repository. The RPM package for CentOS 6 works in CentOS 7 as well.

# wget
# yum install checkinstall-1.6.2-3.el6.1.x86_64.rpm

Once CheckInstall is installed, you can use the following command to build a package for particular software.

# checkinstall <install-command>

Without install-command argument, the default install command make install will be used.

Build an RPM or DEB Pacakge with CheckInstall

In this example, I will build a package for htop, an interactive text-mode process viewer for Linux (like top on steroids).

First, let's download the source code from the official website of the project. As a best practice, we will store the tarball in /usr/local/src, and untar it.

# cd /usr/local/src
# wget
# tar xzf htop-1.0.3.tar.gz
# cd htop-1.0.3

Let's find out the install command for htop, so that we can invoke CheckInstall with checkinstall command. As shown below, htop is installed with make install command.

# ./configure
# make install

Therefore, to build a htop package, we can run checkinstall command without any argument, which will then use make install command to build a package. Along the process, the checkinstall command will ask you a series of questions.

In short, here are the commands to build a package for htop:

# ./configure
# checkinstall

Answer y to "Should I create a default set of package docs?":

You can enter a brief description of the package, then press Enter twice:

Enter a number to modify any of the following values or Enter to proceed:

Then CheckInstall will create a .rpm or a .deb package automatically, depending on what your Linux system is:

On CentOS 7:

On Debian 7:

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean