Here is an extra tip to make uninstalling software compiled from source a little easier.
After switching to root to begin installing (but before issuing the actually install command) run the following:
find /etc /opt /usr ! -type d -print > dir_list_before_install
This will create a listing of all the files (including symlinks) currently present in within /etc /opt /usr (including subdirectories like /usr/local). These are the most likely directories where the program will install new files (add further top level directories if you like, e.g. /bin).
Next run the install command, in many cases that will be:
(Note: Refer to the README/INSTALL file or authors website to confirm the actual install command)
Next repeat the find command, this time outputting to a different file:
find /etc /opt /usr ! -type d -print > dir_list_after_install
Now with diff and a bit of cleanup via sed you can create a log of all newly installed files, like so:
diff dir_list_before_install dir_list_after_install | sed -n 's/^> //p' > application-name_install.log
You should then inspect application-name_install.log in a text editor to satisfy yourself that it only lists files associated with the program you just installed. It is possible that if you had some other software installation process running in the background (e.g. your distro's native update mechanism), then some extra, unrelated files could have been included in the log. If you see anything listed that you know shouldn't be there, remove it from log manually and save the file (you can keep it within the extracted application source directory you store in within /usr/src/).
Later if you need to remove the software and no adequate uninstall method is provided, you can use the application-name_install.log to do the uninstall, e.g. as root cd into the directory where application-name_install.log is stored and issue:
cat application-name_install.log | xargs -d'\n' -n1 rm -v
(Tip: Even if an uninstall method is provided and you decide to use that, you can still use the log to confirm that everything was actually removed.)
Before removing you might want to backup the software for potential reinstall later, like so:
cat application-name_install.log | tar cvaPf application-name_backup.tar.bz2 -T-
You can then reinstall (without having to compile again) via:
tar xvPf application-name_backup.tar.bz2
You can also use a "package" like this to copy the software to another similarly configured (same distro, distro version, arch) machine. This saves you from having to compile again.
Some extra points on this method. You will note that I only log files (including symlinks) that are created, not directories. This is done for several reasons. It keeps the logs less bloated, it allows for simple "one liner" uninstall commands like the one above and finally most directories end up being shared among many packages, making it trickier to work out which to remove. Furthermore for the most part empty directories have little effect on your system and are safe to simply ignore. If it ever bothers you you can always construct a find command using the "-empty" option to track down old empty directories that you might want to consider removing or manually inspect the parent directories of the files within your application-name_install.log. To remove a directory structure that only contains several empty nested directories read up on the '-p' option in the rmdir man page or look for examples online. The other problem with this method is it only tracks new
files, not altered
files. Usually this is not a problem but it could be with more complex applications, so this is worth bearing in mind. Personally, I don't think this is a reason not to log the install as it is always better than nothing.
For a more comprehensive solution to tracking source code installations, a number of great tools are readily available e.g. paco, src2pkg, checkinstall, slacktrack, etc. Read up on them and see which one best suites your workflow. Better yet, read the documentation provided by your distro on creating native packages. This will take more effort initially but allows you to use native tools not only to install and remove but also to run query commands against the contents of the packages you create.