Introduction

Wine is an application that allows you to run Windows programs on a Linux system. Wine is similar to an emulator, but with a different technology that improves performance.

In this tutorial learn how to install Wine 4.0 Stable Release on Ubuntu 18.04.

how to install wine on ubuntu

Prerequisites

  • A user account with sudo privileges
  • Access to a terminal window (Ctrl-Alt-T)

Installing Wine on Ubuntu

Wine uses a different application for 32-bit and 64-bit versions of Ubuntu.

To view CPU details, enter the command:

lscpu

The CPU op-mode(s) field tells you which architecture you’re using:

CPU op-mode(s): 32-bit: You have a 32-bit OS
CPU op-mode(s): 64-bit: You have a 64-bit OS
CPU op-mode(s): 32-bit, 64-bit: You support both

Check CPU architecture with lscpu

Install Wine from Default Repositories

Installing Wine from the default Ubuntu repositories is the easiest option. However, be aware that it may not provide the latest version.

1. Start by updating your apt repository package list. This ensures you install the latest stable version of Wine.

sudo apt upgrade

2. To install 64-bit Wine, enter the following:

sudo apt install wine64

To install 32-bit Wine, enter the following:

sudo apt install wine32

3. After the operation completes, verify the installation by checking the running version:

wine ––version

output that was is not installed

The image above indicates that Wine32 is not installed. However, Wine64 is installed and its version is 3.0.

Installing Wine from the official Ubuntu repository will always give you a stable install. However, the repositories may not include the latest versions.

Install Wine From WineHQ Repository on Ubuntu

If you need a more recent version of Wine, you can install it from the developers’ repositories.

1. Make sure Wine isn’t already installed by checking the version.

wine ––version

2. To get the package name, enter the following:

sudo apt list ––installed | grep –i wine

If you’re using a 64-bit OS, start by enabling 32-bit architecture:

sudo dpkg ––add-architecture i386

3. Add the signing key:

wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key

The signing key verifies authentic software is being installed.

signing key of wine

4. Next, add the Ubuntu 18.04 software repository to download from:

sudo apt-add-repository ‘deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main’

5. Update the package lists:

sudo apt update

6. To Install the latest stable release of Wine 4, use the command:

sudo apt install --install-recommends winehq-stable

7. To install the latest development release of Wine 4, use the command:

sudo apt install --install-recommends winehq-devel

Note: The apt package manager typically handles any dependencies. If you get an error that a dependency is missing during the Wine installation, install each missing dependency with the command:

sudo apt install <package_name> 

 

Then rerun the installation command.


Get Started Using Wine

Launching Applications

If you’re running a GUI on Ubuntu, double-click a Windows .exe file to launch it. Wine automatically associates itself with the .exe file extension. You can also right-click the application and select Open With > Wine.

To launch an application from the command line, enter the following:

cd ‘/.wine/drive_c/program_folder’
wine launcher.exe

It’s essential to change your working directory to the location of the application files. Replace program_folder with the actual directory that holds the application. Replace launcher.exe with the executable file for the application.

Wine Start Command

The wine start command is more robust than the basic wine command. It allows Wine to handle the working directory. Use it to specify a path to a specific location:

wine start ‘C:\program_location\launcher.exe’

Specify a Linux path:

wine start /unix “$HOME/program_location/installer.exe

Use the wine or wine start command to launch the installer for the Windows application.

To download an installer to a local directory, use wget and then use the wine command to launch the installer. The application will install as it would on Windows. When installing from a disc, use the wine start command to specify the path to the installer. Use this to change drives in the middle of installation, if needed.

For security, do not run wine as a root user. Doing so can allow viruses and malware to infect your system.

How to Update Wine

Wine is updated frequently. To manually update wine, use the command:

sudo apt-get upgrade winehq-stable

Replace stable with devel for the developer version.

Stable releases come out every 10-12 weeks. Developer updates come out much more frequently.

By default, wine creates an installation directory in your home directory. It uses a virtual c:\ drive to interpret commands. You can find this directory at /$HOME/.wine/drive_c/.

How to Uninstall Wine

To uninstall wine:

sudo apt remove wine[version]

Instead of wine[version], type wine64 or wine32 according to the version you have installed (32-bit or 64-bit).

This will remove Wine, but not its dependencies. To remove all unecessary dependencies, run the command:

sudo apt autoremove

Removal of these remaining folders will need to be done manually. Run the following commands:

rm -rf $HOME/.wine
rm -f $HOME/.config/menus/applications-merged/wine*
rm -rf $HOME/.local/share/applications/wine
rm -f /.local/share/desktop-directories/wine*
rm -f /.local/share/icons/????_*.xpm

After deleting the files and directories, run:

sudo apt-get remove –purge wine

Now to correct any installation errors, run:

sudo apt-get update
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove

Wine should be totally removed from your system.

Conclusion

Wine is a powerful tool that allows you to run Windows programs in Linux. This guide provided a solid start for installing and running wine on Ubuntu.