How can I purge wine from my Ubuntu 22.04 if I didn't install it by sudo apt install?
- User
How can I purge wine from my Ubuntu 22.04 if I didn't install it by sudo apt install?
- Assistant
If you didn't install Wine using
sudo apt install, it was likely installed through another method such as adding the WineHQ repository, using a different package manager (like Snap or Flatpak), employing tools like PlayOnLinux or Lutris, or compiling it from source. To completely remove Wine from your Ubuntu 22.04 system, follow the steps below based on how Wine might have been installed:1. Check and Remove APT-Based Installations
Even if you didn’t use
sudo apt install wine, other methods might have installed Wine-related packages via APT (Advanced Package Tool).-
List Installed Wine Packages:
dpkg --get-selections | grep -i wine -
Purge Wine Packages:
If you find any Wine-related packages, remove them using:
sudo apt purge 'wine*' -y sudo apt autoremove -y
2. Remove WineHQ Repository (If Added)
If you added the WineHQ repository to install Wine, you should remove it:
-
List WineHQ Repository Files:
ls /etc/apt/sources.list.d/ | grep -i wine -
Remove WineHQ Repository Files:
sudo rm /etc/apt/sources.list.d/winehq*.list -
Update APT Cache:
sudo apt update
3. Uninstall Wine Installed via Snap
Wine can be installed as a Snap package. To check and remove it:
-
List Snap Packages:
snap list | grep -i wine -
Remove Wine Snap:
If you find a Wine Snap package, remove it using:
sudo snap remove [wine-snap-name]Replace
[wine-snap-name]with the actual name of the Wine Snap package.
4. Uninstall Wine Installed via Flatpak
If you used Flatpak to install Wine, follow these steps:
-
List Flatpak Packages:
flatpak list | grep -i wine -
Uninstall Wine Flatpak:
flatpak uninstall [wine-flatpak-name]Replace
[wine-flatpak-name]with the actual name of the Wine Flatpak package.
5. Remove Wine Installed via PlayOnLinux or Lutris
If you used tools like PlayOnLinux or Lutris to manage Wine installations:
-
PlayOnLinux:
- Open PlayOnLinux from your applications menu.
- Select Configure.
- Choose the Wine version or virtual drive you want to remove.
- Click Remove.
-
Lutris:
- Open Lutris from your applications menu.
- Navigate to the Runners section.
- Select Wine.
- Click Remove to uninstall the Wine runner.
6. Uninstall Wine Compiled from Source
If you compiled Wine from source, you'll need to manually remove the installed files:
-
Navigate to the Source Directory:
If you still have the source directory where you compiled Wine, navigate to it. For example:
cd ~/wine-source-directory -
Run Uninstall Command:
sudo make uninstallNote: If you no longer have the source directory, you'll need to manually remove Wine files, typically located in
/usr/local. For example:sudo rm /usr/local/bin/wine sudo rm -rf /usr/local/share/wine sudo rm -rf /usr/local/lib/wine sudo rm -rf /usr/local/include/wine
7. Remove User-Specific Wine Configuration and Data
Regardless of how Wine was installed, user-specific configurations and data are stored in your home directory. To remove them:
rm -rf ~/.wine rm -rf ~/.local/share/applications/wine rm -rf ~/.config/wine8. Verify Removal
-
Check for Wine Executable:
which wineIf it returns a path, you may need to remove the executable manually:
sudo rm $(which wine) -
Search for Remaining Wine Files:
To ensure all Wine-related files are removed, you can perform a comprehensive search:
find / -iname "*wine*" 2>/dev/nullReview the output and manually delete any remaining Wine files or directories that you recognize as part of the Wine installation.
9. Clean Up APT Sources and Dependencies
After removing Wine, it's good practice to clean up any residual packages and update your package lists:
sudo apt autoremove -y sudo apt autoclean sudo apt update10. Optional: Remove PPAs Related to Wine
If you added a PPA (Personal Package Archive) for Wine, remove it to prevent future package updates from that source.
-
List All PPAs:
ls /etc/apt/sources.list.d/ -
Identify Wine-Related PPAs:
Look for files related to Wine, such as
winehq.listor similar. -
Remove the Wine PPA:
sudo add-apt-repository --remove ppa:repository-nameReplace
ppa:repository-namewith the actual PPA name related to Wine.
Final Notes
-
Backup Important Data: Before performing system-wide removals, ensure you backup any important data to prevent accidental loss.
-
Use Caution with
rm -rf: Therm -rfcommand is powerful and can delete files irreversibly. Double-check paths before executing.
By following these steps, you should be able to completely purge Wine from your Ubuntu 22.04 system, regardless of the installation method you initially used.
-