How to Install Wine on Ubuntu

February 3, 2022

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 on Ubuntu.

Prerequisites

Install Wine from Ubuntu Repository

Step 1: Verify Ubuntu 32-bit or 64-bit system

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 are 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

Verify Ubuntu 32-bit or 64-bit system before installing Wine.

Step 2: 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 the apt repository package list. This ensures the latest stable version of Wine is installed.

sudo apt update

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

Step 3: Verify Wine Version Installed

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

wine --version
Check Wine version to confirm installation.

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

Note Learn how to install FFmpeg on Ubuntu, a command-line tool that enables you to work with multimedia content.

Alternative Option: Install Wine From WineHQ Repository

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

1. If you are using a 64-bit OS, start by enabling 32-bit architecture:

sudo dpkg --add-architecture i386

2. Then, update the repository again:

sudo apt update
Enable 32-bit architecture to install Wine repository.

3. Add the GPG key:

wget -qO- https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
Add the GPG key for the Wine repository.

4. Then, run the following commands to add the WineHQ repository to Ubuntu:

sudo apt install software-properties-common
sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ $(lsb_release -cs) main"
Add the WineHQ repository to Ubuntu.

5. Update the package lists:

sudo apt update

6. Install the latest stable Wine release using the command:

sudo apt install --install-recommends winehq-stable

Alternatively, to install the latest development release of Wine, use the command:

sudo apt install --install-recommends winehq-devel

7. Verify the installation by running:

wine --version
Verify Wine installation by checking Wine version on Ubuntu.

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.

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 the 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 From Ubuntu

To uninstall wine:

sudo apt remove wine[version]

Instead of wine[version], type wine64, wine32, wine-stable or wine-dev according to the version you have installed.

That command removes Wine, but not its dependencies. To remove all unnecessary dependencies, run the command:

sudo apt autoremove

Removal of these remaining folders needs 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 now be totally removed from your system.

Get Started Using Wine

To set up the configuration directory for Wine, run the following command:

wineboot

The command creates the ~/.wine directory and initializes all the components.

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 the 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 installs 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.

Conclusion

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

If you are using a different flavor of Linux, we have this tutorial also available for CentOS 7.

Was this article helpful?
YesNo
Dejan Tucakov
Dejan is the Head of Content at phoenixNAP with over 8 years of experience in Web publishing and technical writing. Prior to joining PNAP, he was Chief Editor of several websites striving to advocate for emerging technologies. He is dedicated to simplifying complex notions and providing meaningful insight into data center and cloud technology.
Next you should read
How To Install Ruby on Ubuntu 18.04
February 25, 2019

In this article, you will find three options to install Ruby for Ubuntu 18.04: either from the Ubuntu...
Read more
How to Install the LAMP Stack on Ubuntu 18.04
February 3, 2022

A LAMP stack is a set of open source software used for web application development. For a web application to...
Read more
How to Install a Desktop (GUI) on an Ubuntu Server
August 4, 2022

Want to add a desktop environment after you install Ubuntu server? By default, Ubuntu Server does not include...
Read more
How to Install Wine 4.0 on CentOS 7
July 13, 2019

Wine is free software that allows you to run Windows applications on other systems, including Linux, Mac...
Read more