Step 1: Stop apache2 service from running
Before uninstalling enter this command into Terminal/other CLI:
sudo systemctl stop apache2.service
Step 2: Remove package binaries, system-wide configuration files, and orphaned dependencies
To completely remove the package itself, along with its system-wide configuration files and any dependencies that were required by the package but no longer needed, execute:
sudo apt-get purge --auto-remove <packagename>
Explanation: purge
does the same thing as apt-get remove --purge
; it gets rid of the package itself and associated configuration files. It's like one step above apt-get remove
, which only deletes the binaries. --auto-remove
does the same thing as apt-get autoremove
; it gets rid of orphaned dependencies.
Sorry I didn't give you that specific command to use in the comments, but it's perfectly fine to do everything using separate commands rather than one single command, since the same actions are performed. In your specific case, since you've already done remove --purge
, you can just execute the autoremove part now with sudo apt autoremove
and that should take care of the stuff that remove --purge didn't delete. The single-entry way is just a bit faster.
Alternatively, if you want to be selective about what dependencies get removed, you can get rid of the --auto-remove
flag (executing sudo apt-get purge <packagename>
) and follow the steps I found from this amazing answer to easily create a sort of custom dependency-uninstaller. The following command first lists all package dependencies, then pipes that list into individual apt-get remove
commands, which all gets sent to a shell script that you can open in a text editor and modify as needed. Then you just execute the shell script once you're happy with it. The command is:
apt-cache depends <packagename>|awk '{print "sudo apt-get remove "$NF}' >pg_remove.sh
The pg_remove.sh file is saved to your home directory (obviously you can add a path before the output file name if you want to save it somewhere else). To run the script execute bash pg_remove.sh
(again if your output file is not in your home directory, modify this command to include the path to its location).
Step 3: Remove user configuration files
Next you have to manually remove user-specific configuration files stored in your home directory. These may be in their own directory, and/or in ~/.config, ~/.cache, ~/.local.
First look for files that contain the package name in ~/.config
and remove them. You can use ls -a ~/.config
or ls -A ~/.config
to see all the contents of your home, including hidden files/folders. If you're using Nautilus to do this, make sure you have enabled the option to view hidden files (View>Show Hidden Files
). Then delete them using rm or Nautilus.
Also look in your home folder for a directory with the package name (or something that looks like the package name--it may not be exactly the same). It will probably be hidden by default, and it will probably begin with a "."--if it exists. I don't know that much about apache so I'm not sure if this directory will be there, or what it would look like. Anyway, if it exists, remove it also!
Additionally, check in ~/.cache
and ~/.local/share
for a directory named after the package.
References for Steps 2 and 3: How can you completely remove a package?, What is the correct way to completely remove an application?, How to remove configuration files completely
Possible future reinstallation
This package may have libraries you you actually need in the future and you may need to reinstall it. Ubuntu comes with libapache2-mod-wsgi-py3 installed, which is like a default version, so my guess is that it couldn't play nicely with whatever Python version you were using. If you want to know more check the output of which python
and ps -fA | grep python
...If a conflict with the Python version was indeed the problem, then this question and this one address how you can properly install mod-wgsi via pip (the package pip installs is something called mod_wgsi).
2.7
,3.5
, and '3.6' – SineCo Apr 26 '18 at 17:43which python
andps -fA | grep python
? – Hee Jin Apr 26 '18 at 18:34sudo apt purge
(more thorough than remove). If you can't uninstall with synaptic or apt purge, it might be because apache is running and using (or trying to use?) the package...executesudo systemctl stop apache2.service
and then try again – Hee Jin Apr 26 '18 at 18:38--purge
after stopping apache2 service. But I am not sure now how to check it is completely removed or not. Thanks again!! – SineCo Apr 26 '18 at 18:55