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.
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.
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:
sudo make uninstall
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
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.
make -n install
-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.
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
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.
sudo rm -rf /path/to/package/files
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.
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.
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.
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.
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.
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.