DEV Community

Cover image for Run Windows Applications in Linux Environment.
Emma Odia
Emma Odia

Posted on • Updated on

Run Windows Applications in Linux Environment.

Problem: If you are a Linux user who recently ported from the Windows environment not necessarily because you despise explorer (Lols… I couldn’t resist throwing shade here!). Well if you will be honest enough, you will then admit that there some apps that you are missing out on in the Linux environment. This article is not meant to debate the use of virtual environments or dual booted machines (Hypocrites! Lols… Another shade!) rather it is the path to the gold mine patch that nicely integrates Windows packages in Linux based environments that it possesses an even sweet name.

Hear hear all ye Linux beer gulpers that seek the serendipity of the windows cocktails, bear with me and exchange the savor of the beer mug and bring wine glasses to pour some and join in the toast. There is a nice package that is actually called wine which we can use to run windows based packages in a Linux environment!

What is Wine?

According to the user manual on the Website

“Different software programs are designed for different operating systems, and most won't work on systems that they weren't designed for. Windows programs, for example, won't run in Linux because they contain instructions that the system can't understand until they're translated by the Windows environment. Linux programs, likewise, won't run under the Windows operating system because Windows is unable to interpret all of their instructions.

Wine makes it possible to run Windows programs alongside any Unix-like operating system, particularly Linux. At its heart, Wine is an implementation of the Windows Application Programming Interface (API) library, acting as a bridge between the Windows program and Linux. Think of Wine as a compatibility layer, when a Windows program tries to perform a function that Linux doesn't normally understand, Wine will translate that program's instruction into one supported by the system.”

You can read more about wine here

Install wine of your Linux PC.

Go to winehq.org/downloads. Select your Linux distro from the list of available options and you will land on a page with further instructions of installing the said distribution.

Here is the step by step approach to the Ubuntu install. You will need a working internet connection for this and it should take 10 minutes in all:

First if your Linux environment is 64 bit and has not been enabled to run 32 bit architecture, run this command:

sudo dpkg –add-architecture i386
Enter fullscreen mode Exit fullscreen mode

Next, we will install the wine package from the wine repository. This way we can install future releases from the terminal. Run each of the following commands, one before the other.

wget -nc https://dl.winehq.org/wine-builds/Release.key

sudo apt-key add Release.key

sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
Enter fullscreen mode Exit fullscreen mode

Run the following command in place of the last command if you have a Linux Mint version 18.x

sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'
Enter fullscreen mode Exit fullscreen mode

As often with running new installations on Linux, update all the packages:

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Next is to install the wine package itself. I recommend installing the stable package. Run this command to do that:

sudo apt-get install --install-recommends winehq-stable
Enter fullscreen mode Exit fullscreen mode

If apt-get complains about missing dependencies, install them, then repeat the last two steps (update and install).

Set up the wine configuration environment

Before using Wine, it is necessary to create the fake C: drive where your Windows applications will be installed. To do this open the terminal and enter the following command.

winecfg
Enter fullscreen mode Exit fullscreen mode

Follow all the prompts to install packages and set the Windows environment which will you be prompted to choose a version of. When this step is completed, wine is now set up on your Linux environment and you can check if wine is installed by running:

wine --version
Enter fullscreen mode Exit fullscreen mode

Install a windows app

To install Windows applications using Wine, follow these instructions:
1. Download the Windows application from any source, downloading the .exe (executable file).
2. Place it in a convenient directory (e.g. the desktop, or home folder).
3. Open the terminal, and cd into the directory where the .exe file is located.
4. Type wine the-name-of-the-application.extension

wine realplayer_installer.exe
Enter fullscreen mode Exit fullscreen mode

This will run the .exe using Wine. If it is an installer, it should then run as it would in Windows. If the application asks for a directory to install the application to, select put it under C:\Program Files.

To test this you can install the Balsamiq mockups creator for window here. Using the above instructions will become
cd /home/user/Desktop

If the file downloaded into that dir, then run:

wine Balsamiq_Mockups_3.5.15.exe
Enter fullscreen mode Exit fullscreen mode

This will install Balsamiq, after the installation. Launch the Balsamiq app and begin to use!

To start/run Windows programs using Wine

After installing an application using the directions above, those applications can be started and used by entering wine programname.exe (e.g. wine realplayer.exe). When done, close the application as one would normally. You must run the installed executable, which will by default be in the virtual Windows drive created by Wine, at ~/.wine/drive_c. Generally programs will install themselves somewhere under Program Files inside the virtual Windows drive, following Windows conventions.

You can also use the Wine file browser, by running winefile in a terminal. Clicking the C:\ button in the toolbar will open a window where you can browse the virtual Windows drive created in .wine. Double Clicking an executable in the Wine file browser will run it in Wine.

Instead of having to always enter the terminal or use the Wine file browser, you may also create a desktop icon, and start a Wine application using that icon. To do this, right click on the desktop and select "Create a launcher." If you wish, select an icon from the list of available icons (or browse to an icon you would like to use), fill out other information that is requested (Name, generic name, etc.). For the command, type in wine the-location-of-the-program.exe (e.g. wine /home/john/.wine/realplayer.exe). The most important part of creating a launcher is the command, the generic name is not as important. Just make sure you de-select "Run in terminal." This completes the process.

In some cases the application requires to be running from a certain location. In this case create launcher with command

sh -c "cd /home/USER/.wine/drive_c/Program Files/Appdir/; wine /home/USER/.wine/drive_c/Program Files/Appdir/game.exe"
Enter fullscreen mode Exit fullscreen mode

Of course you will need to replace USER and Appdir with the proper data.
If you desire to have an icon on the panel, create a launcher on the panel of choice. Do this by right-clicking the panel, selecting "Add to Panel," and selecting "Custom Application Launcher." This will ask you for the same information as before.

Alternatively, to make life easier, you can set it so wine will automatically open .exe files files for you - instead of using the Wine File to locate the file each time. To do so, right click on the .exe file, select Properties, and then select the Open With tab. Click the 'Add' button, and then click on 'Use a custom command'. In the line that appears, type in wine, then click Add, and Close. Now all .exe files will be automatically opened by Wine, so you can use Nautilus to browse and open them instead of the Wine File.

Uninstalling Wine Applications

Open up a terminal window and type the command below:

wine uninstaller
Enter fullscreen mode Exit fullscreen mode

What this will do is open up a program similar to the Windows add/remove programs control panel, allowing you to uninstall applications from a Wine installation. Running uninstall programs directly via Wine should also work normally. Alternatively, you could also simply delete the folder of the application. However, as when done in Windows, this method will be unclean and will not remove the program's configuration from the Wine registry like using an uninstaller will.

Enjoy!

Credits:

Winehq User Guide
Ubuntu Community
Papa Google

Top comments (0)