Uninstall files installed from a source code tar-ball

by on December 24, 2005 · 7 comments· LAST UPDATED September 11, 2007

in , ,

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

Two methods can be used to uninstall files:

Method # 1: make command

Use command make uninstall or equivalent supported command, Read INSTALL or README file in source code file to find out more about this method.

# make uninstall

Sure, this method sounds very easy but not supported by all tar balls.

Method # 2: find command

(a) 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

(b) Now install the software (use configure & make to compile it)

make
make install

(c) Now make a list of all files on the system after installing software i.e. postinstall list

find /* > packagelist.after

(d) Next, compare both lists using the diff utility to find out what files are placing where. This list can be use to uninstall all files installed using source tar ball.
diff packagelist.b4 packagelist.after > package.uninstall.list

(e) After some time if you wish to uninstall files then you need to get list of files from package.uninstall.list file. Use following small for loop at shell prompt to remove all files:

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

A note about binary packages

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 Anonymous December 26, 2005 at 7:38 pm

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…

Reply

2 Anonymous December 26, 2005 at 10:54 pm

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

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

Code:
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.

Reply

3 Stoyan December 27, 2005 at 7:43 pm

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

Reply

4 LinuxTitli December 27, 2005 at 11:22 pm

Stoyan,
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 :D

Reply

5 Stoyan December 28, 2005 at 9:29 am

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.

Reply

6 LinuxTitli December 28, 2005 at 11:08 am

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!

Reply

7 Shijith T August 7, 2010 at 4:29 pm

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.
:D

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous post:

Next post: