Uninstall files installed from a source code tar ball on Linux or Unix

Installing software from a source code is common practice in Linux and Unix world. Some time this is preferred method because it gives all power and flexibility you need to optimize your software such as MySQL, PHP, Apache and more. However, uninstalling files installed from a source code tar ball can be a big headache.

Two methods can be used to uninstall files:

Method # 1: make command

Use the make command to uninstall or equivalent supported command to uninstall files. You need to read INSTALL or README file in source code to find out more about this method.

# make uninstall

This method sounds very easy but not supported by all tar balls make file.

Method # 2: find command

First, make a list of all files on the system before installing software i.e. a pre-installation list of all files on your system:

find /* > packgetlist.b4

Next compile and install the software (use configure & make to compile it):

./configure --option=1 --foo=bar etc
make install

Now, make a list of all files on the system after installing software i.e. postinstall list:

find /* > packagelist.after

Finally compare both lists using the diff utility to find out what files are placed where. This list can be use to uninstall all files installed using source tar ball.
diff packagelist.b4 packagelist.after > package.uninstall.list
Say, if you wish to uninstall files then you need to get list of files from package.uninstall.list file. Use the following small for loop at shell prompt to remove all files:

for i in $(grep ">" package.uninstall.list | awk '{ print $2 }')
 /bin/rm -fi "$i"

A note about binary packages

If you are using a Debian / Ubuntu Linux, use the following apt-get command to uninstall binary package:
sudo apt-get remove {package-name}
If you are using a Redhat / RHEL / Fedora / CentOS / Suse Linux, use following yum command to uninstall binary package:
rpm -e {package-name}
OR (mostly Redhat and friends):
yum remove {package-name}

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

🐧 9 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
9 comments… add one
  • Anonymous Dec 26, 2005 @ 19:38

    Very, very risky if some other files were created during the install process that have nothing to do with the package in question.

    Just review that diff output…

    • tele Feb 23, 2015 @ 21:20

      I have problem with method 2
      – not find all files ( I used this command with root )
      – (a) command and (d) command have other names
      (a) packgetlist.b4
      (d) packagelist.b4

      • tele Feb 23, 2015 @ 21:29

        find finded files, probably my foult, sorry.

  • Anonymous Dec 26, 2005 @ 22:54

    Well it is not *risky* at all. You can simply replace above command find command with following one
    find /* > packgetlist.b4

    Replace with
    find /* | grep -v -e ^/proc/ -e ^/tmp/ -e ^/dev/ -e ^/home/ > packgetlist.b4

    find /* > packagelist.after
    find /* | grep -v -e ^/proc/ -e ^/tmp/ -e ^/dev/ -e ^/home/ > packagelist.after

    Above command will not include directories /proc, /tmp /dev /home. User can create files in /home or /tmp only so no one else could create file in /usr or somewhere else. So it is totally safe to use this method. We use this method everyday. Before running for loop you better check out file package.uninstall.list and then remove files.

  • Stoyan Dec 27, 2005 @ 19:43

    Take a look on checkinstall. Can produce also .deb and .rpm from sources. In your case just: checkinstall make install will be maybe enough. For debian see also: Installing packages from source code with checkinstall

  • LinuxTitli Dec 27, 2005 @ 23:22

    Ok you can create Slackware, Red Hat, or Debian packages from source code with checkinstall. However, CheckInstall does not yet allow creating a package without automatically installing it, though this may change in future releases… Anyway, I will post it about it some time later about your suggestion. Thanks for link 😀

  • Stoyan Dec 28, 2005 @ 9:29

    I personaly using CRUX, which have extreamly good package management tools. See: pkgutils – can create pkg from sources, install, uninstall etc. And it is very easy to be used on non-CRUX distros too. See also prt-get, which is a pkgutils extension for working with ports-like collection.

  • LinuxTitli Dec 28, 2005 @ 11:08

    My workplace requires me to work on Debian, RHEL, or Suse only. I may try CRUX at home. To be frank I like FreeBSD ports system it is easy to use!

  • Shijith T Aug 7, 2010 @ 16:29

    Install checkinstall. CheckInstall keeps track of all the files created or
    modified by your installation script (“make install”
    “make install_modules”, “setup”, etc), builds a
    standard binary package and installs it in your
    system giving you the ability to uninstall it with your
    distribution’s standard package management utilities.

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