Software & AppsOperating SystemLinux

How To Completely Uninstall a Package Built from Source

Ubuntu 9

In the world of Linux, installing packages from source can provide the latest features and customizations that pre-built packages may not offer. However, the uninstallation process can be a bit tricky. This article will guide you on how to completely uninstall a package built from source.

Quick Answer

To completely uninstall a package built from source, you can use the make uninstall command in the source code directory. If that doesn’t work, you can try reversing the installation steps manually or use the checkinstall tool to create a package that can be installed and removed using your package manager. As a last resort, you can manually remove the installed files, but be cautious as it can be risky.

Using make uninstall

The standard way to remove a package installed from source is to use the make uninstall command. This command should be run in the directory containing the source code. Here is how you can do it:

cd /path/to/source/directory
sudo make uninstall

The make uninstall command works by invoking the uninstall rule in the Makefile, which is a script used to compile and install the software. The sudo command is used to run the command with root privileges, which is often necessary when modifying system files.

However, not all packages include an uninstall rule in their Makefile. If the make uninstall command doesn’t work, you may see an error message like “No rule to make target ‘uninstall'”. In this case, you’ll need to use a different method to remove the package.

Reversing the Installation Steps

If make uninstall doesn’t work, you can try to reverse the installation steps manually. To do this, you can run make -n install to list the steps that were performed during the installation. Then, you can manually undo those steps.

cd /path/to/source/directory
make -n install

The -n option tells make to print the commands it would normally execute but not actually execute them. This gives you a list of the installed files and directories, which you can then remove manually.

Be careful when using this method, as it requires a good understanding of the Linux file system and the risks of removing system files.

Using checkinstall

A safer and more convenient way to manage packages installed from source is to use checkinstall. Instead of using make install, you can use checkinstall to create a package that can be installed and removed using your package manager.

Here’s how to use checkinstall:

cd /path/to/source/directory
sudo checkinstall

This will create a package (a .deb file for Debian-based systems, or a .rpm file for Red Hat-based systems) and install it. To uninstall the package, you can use your package manager’s remove command:

# For Debian-based systems
sudo apt-get remove <package-name>

# For Red Hat-based systems
sudo yum remove <package-name>

Manually Removing Installed Files

As a last resort, if none of the above methods work, you can manually remove the installed files. You can use the whereis command to find the directories where the binaries and files are installed, and then use the rm command to remove them.

whereis <package-name>
sudo rm -rf /path/to/package/files

The whereis command locates the binary, source, and manual page files for a command, and the rm -rf command removes files and directories recursively and forcefully.

Be extremely careful when using the rm -rf command, as it can delete essential system files if misused. Always double-check the paths and files you are about to delete.


Uninstalling a package installed from source can be a bit more complex than uninstalling a package installed from a package manager. However, with careful tracking of the installation steps and the use of tools like checkinstall, it’s entirely manageable. Always remember to take precautions when modifying system files, and don’t hesitate to ask for help if you’re unsure about something.

Can I uninstall a package built from source using the package manager?

No, packages installed from source are not managed by the package manager, so you cannot uninstall them using the package manager’s remove command. You will need to follow the steps mentioned in the article to uninstall the package.

How do I know if a package includes an uninstall rule in its Makefile?

You can check the Makefile in the source code directory for an uninstall rule. Look for a target named "uninstall" or a similar name. If it exists, you can use the make uninstall command to uninstall the package. If it doesn’t exist, you’ll need to use alternative methods mentioned in the article.

Can I use `checkinstall` to create a package for any package installed from source?

checkinstall is a tool that works well with packages that follow the standard installation process using the make install command. However, not all packages may be compatible with checkinstall. It’s best to consult the documentation or the package’s website to see if checkinstall is recommended for that specific package.

Is it safe to manually remove installed files?

Manually removing installed files should be done with caution. Make sure you are removing the correct files and directories associated with the package you want to uninstall. Removing essential system files can cause problems with your Linux system. Always double-check the paths and files you are about to delete and proceed with caution.

What should I do if I encounter any issues while uninstalling a package built from source?

If you encounter any issues or are unsure about the uninstallation process, it’s best to seek help from the package’s documentation, online forums, or the Linux community. They can provide guidance specific to the package you are trying to uninstall and help troubleshoot any problems you may encounter.

Leave a Comment

Your email address will not be published. Required fields are marked *