Uninstalling software in Linux

Angel Tsankov fn42551 at fmi.uni-sofia.bg
Tue Aug 15 07:11:51 PDT 2006

>>>Really simple way:
>>>Run ./configure and make as usual, but don't make install yet.
>>>Run touch /baseline (any file works) to set a baseline date.
>>>Run make install.
>>>Run find / -cnewer /baseline | sed -e '/^\/proc/d' -e '^\/sys/d' >
>>>/packagename.txt .  This will show all of the files that were updated
>>>in the make install.
>>>Then you can just run rm `cat /packagename.txt` to remove the package.
>>Hmm, this seams a very neat solution, but one need to be very careful when applying it in a multi-user environment (even in a 
>>multi-process one), so that files modified between 'make install' and 'find' do not get accidentally deleted. These could be user 
>>files (ones owned by non-root users) or even configuration or log  files of other programs already installed and running on the 
>>target system.
> Indeed, you have well understood the limitations of this method.
> That's why you should check the contents of /packagename.txt well
> before doing the rm!  In your chroot environment while building
> LFS, you should be quite free from the concurrency effect.
> Also, you can exclude certain directories like /home and /var/log.
> Watch out particularly for shared config files and the like. If the
> make install created a new user for example, the above method
> will zap your entire /etc/passwd!
> A more common example is the installation of packages with texinfo
> pages, which add entries to the top level info directory node. Again,
> the above method will zap /usr/share/info/dir.  You can deal with that
> by the following technique:
>  DIRFILE=`grep "info/dir" /packagename.txt`
>  install-info --dir-file=$DIRFILE --delete \
>      `grep "info/.*\.info.*" /packagename.txt`
> (Don't forget to remove the $DIRFILE line from /packagename.txt
> before the rm!)
> A safer approach is to install into a temp dir and then roll that up into
> a tarball. It usually goes something like this:
>  DESTDIR=/tmp/packagename
>  mkdir $DESTDIR
>  make DESTDIR=$DESTDIR install
>  cd $DESTDIR
>  tar -czf /packagename.tar.gz .
> To install:
>  cd /
>  tar -xzf /packagename.tar.gz
> To uninstall:
>  cd /
>  tar -tzf /packagename.tar.gz | grep -v '/$' |xargs rm -vf
> With this approach, you still have to be careful of the type of
> problem I described above with info/dir.  It is also better to script
> the symlinks rather than to let tar handle them.  So there are
> several things to watch out for but there are solutions for all of
> them and they can all be scripted--once you have done that,
> you will have written your own basic package management tool!

It seems to me that the best way to go (for a Linux novice like me) is to use the uninstall target of makefiles, if one is 
Generally speaking, the doer of smth should also be the one who can best undo it. Anything else is second guessing... And guessing 
smth is not like being certain of it.
Anyway, thanks a lot for the replies! I just wanted to get a notion of what possibilites exist and how reliable they are. 

More information about the lfs-support mailing list