Red Wine in a GlassHeader image for understaning the Wine compatibility layerCSS HTML Validator Logo
HOME Tutorials & Essays About
Tutorials & Essays About

Understanding Wine
It is much like virtual machines

Introduction: Virtual Machines

To explain Wine, I will assume you already have at least a conceptional understanding of a virtual machine, but, to review, take Microsoft's Hyper-V as an example.

If Hyper-V is installed on your PC, you can use it to create virtual machines. If you create several VMs, you can load each one with apps and set them running. If something goes wrong in one VM, that will not affect any other VM, so you just delete the bad guy and re-create it. Better yet, if you had the foresight to make copies of the VMs on a backup disk, when something goes wrong you just delete the bad guy and restore it from backup.

What does that have to do with Wine?

If Wine is installed on your PC, you can use it to create Wine Prefixes. If you create several Wine Prefixes, you can load each one with apps and set them running. If something goes wrong in one Wine Prefix, that will not affect any other Wine Prefix, so you just delete the bad guy and re-create it. Better yet, if you had the foresight to make copies of the Wine Prefixes on a backup disk, when something goes wrong you just delete the bad guy and restore it from backup.

Wine is like Hyper-V? It creates virtual machines?

No. Wine does not create virtual machines. Wine's technology is entirely different, but there is a similarity in how they are used, and thinking of a Wine Prefix as if it were a virtual machine is a way to understand how Wine is used.

However, there is one major difference between how one can use a Wine prefix compared to a virtual machine. A Windows app running in a virtual machine is isolated from the host machine. Special arrangements allow such an app to have limited access to the host's resources, but full integration into the host with seamless access to the host's resources is not to be expected. On the other hand, a Windows app running under Wine is indistinguishable from a native Linux app and, subject to the usual Linux permissions, has full access to the host machine's resources.

Some applications benefit from or require the isolation provided by a virtual machine, but, for many apps, integration as if it were a native Linux app is a reason to strongly prefer Wine over a virtual machine. As examples, text and HTML editors are most useful if they have full access to all of a user's resources, and that makes them good candidates for a Wine prefix, while tax preparation software, such as TurboTax, works well isolated from the host system, so there is no downside to hosting it in a virtual machine.

So … How do you use Wine on a Linux machine?

The best way to answer that question is to actually do it, so let's make a Wine Prefix and install the Windows app Notepad++ so that we can use Notepad++ to edit text files on a Linux machine. Assuming Wine is already installed, open a terminal window and issue the following two commands.

$ mkdir -v ~/.wine-Npp
$ export WINEPREFIX=~/.wine-Npp

The first of these commands creates a new empty folder, named .wine-Npp, in the home directory, and the second command creates a new environment variable, WINEPREFIX, which has the path to the new folder as its value. That is a good start. Next, we execute winecfg to create a Wine Prefix.

$ wine winecfg

When you come to actually using this command on your own machine, you will see it generate many error messages. Just ignore them. They are the result of unimplemented features which are not needed.

When winecfg finally finishes, folder .wine-Npp is no longer empty. winecfg loaded .wine-Npp with the machinery needed to host and run Windows apps. If you have enabled the Show Hidden Files option in your graphical file manager (Nautilus or other), you can use it to locate and look inside .wine-Npp. Doing that, you will find two folders and four files.



Inside folder drive_c is nothing other than …

Program Files
Program Files (x86)

which is just like C: in MS Windows. Your new Wine virtual machine … uh, I mean, your new Wine Prefix … is installed and ready to go to work.

Next, we install Notepad++.

Browse to https://notepad-plus-plus.orgNew Window Icon and download the Notepad++ installer, currently npp.7.7.1.Installer.x64.exe, into your ~/Downloads folder. Then, in a terminal window, make ~/Downloads the default directory and execute the Notepad++ installer.

$ cd ~/Downloads
$ wine npp.7.7.1.Installer.x64.exe

When done, there will be a launcher for Notepad++ on your desktop. Double-click it to run Notepad++. You can also make Notepad++ the default application for editing .txt files. Looking inside Program Files with a graphical file manager, you find a folder for Notepad++ along with folders for other Windows apps.

Common Files
Internet Explorer
Windows Media Player
Windows NT

What happens when Notepad++ needs to do an update?

Nothing special. Let it update just as it would in MS Windows. If you ever decide you no longer want Notepad++, don't bother with an uninstall. Just delete folder .wine-Npp. That removes all traces of Notepad++ from your system.

Do you have to create a new Wine Prefix for every Windows app you want to install?

No, but one app per Wine Prefix is usually a good way to work. In a single Wine prefix, you can install as many Windows apps as you like, but, if one of them misbehaves so badly that the Wine Prefix becomes unusable, you must delete the Wine prefix and reinstall all the other apps it contained all over again. Keeping to one app per Wine Prefix limits the damage any one app can do. One app per Wine Prefix is regarded as a "Best Practice".

However, this "Best Practice" comes at a cost. On my machine, I have two Wine Prefixes, one for Notepad++ and one for CSS HTML Validator. Whenever I need to issue a Wine command, I must specify which Prefix to apply the command to. This is done by setting the WINEPREFIX environment variable. For example, if I should decide it made sense to install EmEditor in the same Wine Prefix as Notepad++, first, I would set the value of WINEPREFIX to ~/.wine-Npp, and then I would proceed to install EmEditor.

$ export WINEPREFIX=~/.wine-Npp
$ cd ~/Downloads
$ wine msiexec /i emed64_18.9.10.msi

Note that because the installer for EmEditor is an .msi file, a different command, wine msiexec /i, is required for the installation.

What if I don't want to be bothered with multiple Wine Prefixes?

In that case, do not define WINEPREFIX as an environment variable, and don't create an empty folder. Skip those two items, but everything else is the same. When WINEPREFIX does not exist, the wine winecfg command will, by default, create its own empty folder in the home directory and give it the name .wine and load it up with all the necessary machinery. Subsequently, any Wine command will reference this Wine Prefix.

That makes life very easy, and, if you expect to install only one Windows app, it makes perfect sense. When more than one Windows app is installed in ~/.wine, everything will be fine unless one of the apps misbehaves, in which case you may face the problem mentioned above. However, lots of installations hosting more than one Windows app work just fine. Your call.

OK! If a Wine Prefix isn't a virtual machine, what is it?

Wine is a "compatibility layer", and its job is to translate Windows system calls into Linux or Macintosh system calls. See the lead paragraph What is Wine? at WineHQNew Window Icon.

If I want to know more about Wine, where should I go?

The official Wine User's GuideNew Window Icon is good, but note the Work in progress disclaimer at the top of the page.

How To Run Windows Software on Ubuntu with WineNew Window Icon at How-To Geek looks to be a friendly introduction to Wine.

The It's FOSS article How To Run Windows Applications On Linux [Beginners Guide]New Window Icon also looks good.

Wine maintains a database of Windows apps that run on wine at its Wine Application Database (AppDB)New Window Icon.

Facebook Logo   Twitter Logo  Reddit Logo   Quora Logo

Consider sharing your experience

Did you find this page helpful? Have constructive feedback? Wisdom to share?

Send email to Email Address

Privacy PolicyNew Window Icon

A.Z. (initials or other identifier) (date will be here)

… (your comment appears here) …

Graphic image of Athena pouring wine for Heracles, from 470 BC