1. Introduction

Wine is an open-source compatibility layer that enables Windows applications to run on Linux. It works by translating Windows API calls into code that Linux can understand. This means we can use popular Windows applications like Microsoft Office, Adobe Photoshop, and many games without needing a separate Windows installation.

However, there are times when we may need to uninstall Wine, to fix compatibility issues or free up system resources. Further, properly removing it may be necessary to prevent system conflicts and to ensure no residual files or settings remain on the Linux system.

In this tutorial, we’ll cover the necessary steps to completely uninstall Wine from Linux. The goal is to ensure a thorough and clean removal, helping maintain a smooth and efficient operating environment.

2. Important Considerations Before Uninstalling Wine

Before we dive into the uninstallation process, we should close all applications running on Wine to avoid any potential issues. Closing these applications may prevent any unexpected behavior or errors.

Additionally, we should save any unsaved work to avoid data loss. It’s also a good idea to create a backup of important data to ensure data safety.

Finally, we should check if any other application relies on Wine. This includes identifying dependencies, such as libraries or frameworks, that may be shared between Wine and other applications.

3. Uninstalling Wine

We can often uninstall Wine using the native package manager, but the process varies depending on the Linux distribution and repository used for installation.

Specifically, if we’ve used the official repository on Ubuntu, we can uninstall Wine using apt:

$ sudo apt remove wine

However, if we’ve used the WineHQ repository, we may need to remove the WineHQ packages, their dependencies, and the repository itself.

So, first, we uninstall the WineHQ package using its canonical name, winehq-stable:

$ sudo apt remove winehq-stable

Next, we remove the WineHQ repository and its associated key:

$ sudo rm /etc/apt/sources.list.d/winehq
$ sudo rm /etc/apt/keyrings/winehq-archive.key

Thus, by executing these commands, we’re ensuring that the system no longer uses the WineHQ repository as a source for packages.

4. Removing Dependencies and Residual Files

Even after uninstalling Wine, some dependencies and residual files may remain on the system.

To remove the dependencies, we can execute:

$ sudo apt autoremove

This command automatically removes any dependencies of Wine that no other package requires.

Next, we can verify whether Wine has been completely uninstalled:

$ sudo dpkg -l | grep wine
rc  wine-stable                  9.0.0.0~jammy-1          amd64        WINE Is Not An Emulator - runs MS Windows programs
rc  wine-stable-amd64            9.0.0.0~jammy-1          amd64        WINE Is Not An Emulator - runs MS Windows programs
rc  wine-stable-i386:i386        9.0.0.0~jammy-1          i386         WINE Is Not An Emulator - runs MS Windows programs

This command lists all the packages that contain the string wine in their name. If there are remaining packages, we can remove them via apt remove:

$ sudo apt remove wine-stable wine-stable-amd64 wine-stable-i386:i386 winehq-stable

If all packages have been removed, this command should not display any output.

To locate any remaining residual files and directories, we can use the find command:

$ sudo find / -iname "wine*"

This command searches for files and directories that contain the string wine in their name while ignoring case sensitivity.

Once we’ve reviewed the output, we can remove the residual files and directories using the rm command:

$ sudo rm /etc/apt/sources.list.d/winehq-jammy.sources /usr/share/icons/Yaru/24x24@2x/apps/wine.png

When using the rm command, we need to ensure that we provide the correct path to avoid accidentally deleting important system files.

Furthermore, care should be taken with the packages and files, as there can be other installed packages and stored files with the same string in their name that aren’t related to Wine.

5. Removing Wine Installed From Source

When we install Wine from its sources, the native package manager doesn’t manage the installation files. As a result, we can’t use the standard package management commands to uninstall Wine.

Instead, we need to manually remove the installation directory and any associated files.

To do this, we can use the find command to search the Wine installation directory and files:

$ sudo find / -iname "wine*" -type d && sudo find / -iname "wine*" -type f

These commands search for directories (-type d) and files (-type f) named wine or starting with wine in the root directory (/).

Once we’ve located the installation directory, we first verify its contents to confirm it’s the Wine installation we want to remove.

After confirming, we can use the rm command again to remove the installation directory and all its content.

6. Conclusion

In this article, we discussed how we can completely uninstall Wine from a Linux system.

First, we learned that the uninstallation process varies depending on the distribution and repository that we used for installing it. Next, we checked two ways of removing the main Wine packages. Further, we also explored how to handle the case where Wine is installed from sources, which requires a manual approach to remove the installation directory and associated files.

Finally, we addressed how to remove remaining dependencies and residual files to ensure the complete uninstallation of Wine.