How to Install Wine on Ubuntu

Estimated reading: 5 minutes 298 views

Introduction

Wine is a compatibility layer for Linux that allows you to run Windows programs on a Linux system. It translates Windows API calls into native Linux commands, enabling Windows programs to run seamlessly.

This tutorial teaches you how to install Wine on Ubuntu using two different repositories.

Prerequisites

  • A user account with sudo or root privileges.
  • Ubuntu system (this tutorial uses Ubuntu 22.04).
  • Access to the terminal.

How to Install Wine on Ubuntu 22.04?

Here are the sequential instructions for installing Wine on your Ubuntu operating system.

Step 1: Update Your System

To avoid compatibility issues and improve the performance of your Ubuntu 22.04, run the update command to refresh the package list:

apt update

Step 2: Upgrade Installed Packages

You can use the below-mentioned command for upgrading the installed packages on your system:

apt upgrade -y

Once the upgrading process is finished, all of your system packages will be upgraded to the latest release.

Step 3: Enable 32-bit Architecture

Enabling the 32-bit architecture is necessary if you want to use Wine on a 64-bit Ubuntu system. Thus, executing the provided command allows you to install and run 32-bit Windows applications through Wine:

dpkg --add-architecture i386

No output after executing the commands indicates that the 32-bit architecture has been successfully enabled on your machine.

Step 4: Create a Directory for Keyrings

You can create a dedicated folder, such as keyrings, for storing security keys or keyrings on your local machine:

mkdir -pm755 /etc/apt/keyrings

Step 5: Download Wine Repository Key

The following command is essential for downloading the Wine repository key to the keyrings directory:

 wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -O

After running the above command, you will notice a key “winehq-archive.key” saved to the dedicated directory.

Step 6: Add the Wine Source File

Utilize the below command to download and add the Wine repository source file to your local machine:

wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo wget -NP

After executing the command, the completion report will be displayed on your terminal.

Free Ubuntu VPS

Step 7: Refresh Package List

Run the update command to refresh your Ubuntu package list and update with the new installations:

apt update

Step 8: Install Wine Stable Version

Upon completing the above steps, your system is now ready to install the Wine package. Simply, use the command from the terminal to begin the installation process of Wine (stable) on your Ubuntu system:

apt install --install-recommends winehq-stable -y

During the installation, if you didn’t encounter any errors, it indicates that you have successfully installed the Wine package on your Ubuntu 22.04.

Step 9: Verify Wine Installation

You can confirm the installation of the Wine package through the command:

wine --version
wine --version

After using the above command the release number of wine, such as wine-9.0 will appear on your terminal screen.

With the help of the aforementioned process, you have successfully installed Wine on your Ubuntu 22.04 system.

How to install a Windows app

If you’re running a GUI on Ubuntu, right-click the .exe file you want to open, in this case, npp.8.6.Installer.x64.exe, and select Open With Wine Windows Program Loader.

To launch the application from the command line, take the following steps:

Change the working directory to the npp.8.6.Installer.x64.exe location, in this case, the Downloads directory:

cd ~/Downloads

Here is a real example. It installs version 8.6 of the text editor Notepad++. The file name of the Notepad++ installation program is npp.8.6.Installer.x64.exe

wget https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.6.7/npp.8.6.7.Installer.x64.exe
wine npp.8.6.7.Installer.x64.exe

wine --version

More about installing Windows apps

  • The installer does not need to be in ~/Downloads. Any directory is fine, as long as you issue the wine command from that directory.
  • If the installer is a Windows .msi file instead of an .exe, use the wine msiexec /i command instead of wine.
  • Not all Windows apps can run under Wine. Consulting the Wine Application DatabaseNew Window Icon may be helpful.
  • For more information, search for online tutorials on using Wine. One that includes basic information plus some advanced techniques is Installing Windows Apps on LinuxNew Window Icon

How to Uninstall Wine from Ubuntu 22.04?

Completely remove the Wine package from your Ubuntu 22.04 system through the following process.

Step 1: Uninstall Wine Stable

Run the command if you want to completely remove the Wine package:

apt purge wine winehq-stable -y
In your terminal, you can notice the process of removing the package files.

Step 2: Confirm Wine After Uninstallation

You can verify the removal of Linux Ubuntu Wine by using the following command:

wine --version

If the command returns “No such file or directory”, it indicates that Wine is no longer available on your Ubuntu 22.04 system.

Conclusion

You can install the Wine package on your Ubuntu 22.04 machine through simple procedural steps. Start the installation process by adding 32-bit architecture, downloading keyrings, and the Wine source file. Finally, install utilize the command sudo apt install –install-recommends winehq-stable -y to install the wine package.