Complete Guide to Using Wine from the Command Line (Ubuntu)
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
By indubitableness at 2010-03-22 19:26
This tutorial started off as a reddit post that ended up getting out of hand. The original poster asked for guidance regarding gaming in Linux. This tutorial covers relatively advanced (probably closer to intermediate) use of Wine.
Before you start, please be familiar with these pages:
The appdb page is very important. It will tell you which games work and on which versions of Wine they have been tested. The appdb becomes increasingly important when you come across games that need added dll files and/or registry edits to install and run in Wine.
Note: This Answer is Ubuntu specific, because the original poster specifically asked about using Ubuntu.
Before I continue with my rant about gaming on Linux I would like to point out right now that the very first thing you should do when you install your ubuntu set up is to run the following:
This will provide you all your required media codecs for proprietary video and audio formats, which are not included with Ubuntu.
Back to Gaming
Many distros include Wine in their repositories. Ordinarily this will be Wine 1.0.1, the stable release. Instructions for updating to new versions, which the Wine developers do not recommend but I do, can be found at http://winehq.org. If you are using Slackware Linux, you can obtain a trustworthy binary from http://slackware.com/~alien/slackbuilds/wine/.
Wine creates a directory called .wine that resides in your home directory. This directory is what is known as the default wine prefix. WINEPREFIX is the environment variable that dictates where the Wine prefix will be. You can change this variable to a different location in order to separate applications. Each Wine prefix acts as a separate Windows "machine."
The first line shows how to set the Wine prefix, the second line shows how to refer to it. Note that when defining the variable you do not use a dollar sign ($). When referring to the variable in a command the $ must be used to tell the system that it is using a variable.
The $HOME variable is equal to your home directory so it can be used to replace the /home/user bit in the command above. It is recommended that you place all your Wine prefixes within a single directory. You can put this directory wherever you please. I use $HOME/.wine/wineprefixes. It is also useful to set a shortcut variable to this location when working with Wine such as:
As you can see in the above example I have created the variable prefix and set it to represent the absolute path /home/user/.wine/wineprefixes. I declared this variable in my .bashrc file. The second command creates a directory to be used as a Wine prefix. This one is intended for Steam.
Note that the last command in this series ends with winecfg. When running Wine commands such as winecfg, it is important to set the WINEPREFIX variable immediately before running that command. While WINEPREFIX can be set system-wide, it is a clunky and unreliable way of doing things. When you run this command it will prepare the specified Wine prefix, getting it ready for the installation of applications and bringing up a configuration GUI.
Don't Skip This
Pay careful attention to the Drives section of the configuration GUI that pops up, as this is where you can add a D:\ drive and set its location. I use /media/iso, which is where I mount physical disks and disk images when I am installing Wine games. Also be aware of the drive_c directory within any Wine prefix. This is the C:\ directory folder and I heartily recommend working from inside of that directory when installing and running games and apps. Sometimes to run a game you must be working from inside the game's install path itself.
Write scripts to launch your games and make shortcuts to them. This is covered later in this tutorial.
Other commands to be aware of:
wine cmd #Emulates a windows command prompt, required to run batch files
wine regedit #Sometimes you need to make registry edits to get a game working
wineboot #Simulates a windows shutdown, useful for when apps act up
wine msiexec #Used to run msi files. This command accepts Windows
# style arguments. Use /i to install.
wine is the command used to actually run your Wine apps. Make sure you set the Wine prefix to the appropriate place.
user@ubuntu$: cd $prefix/SteamGames/drive_c
user@ubuntu$: WINEPREFIX=$prefix/SteamGames wine ./Program\ Files/Steam/Steam.exeNote: For clarity, note that ./Program\ Files/ above cuts off strangely. Be aware that the backslash \ character is required immediately before the space on the command line to insert the space between Program and Files, otherwise the system will interpret the word Files as a separate command rather than a part of the directory name.
This is the appropriate way to launch a correctly installed Steam application. Remember, you can put your Wine prefixes wherever you want. If you choose to use a variable as a shortcut to your Wine prefix, you can name it whatever you want.
Always remember tab completion. As you can see some of these commands get pretty tedious. Use your bash history and tab completion. Then when you're satisfied with your set up and sure the game or application runs, write scripts to launch them. I store these in $HOME/bin. I also use $HOME/sbin for system scripts.
Be sure to include code to move you into the appropriate working directory.
How Do I Install the Application?
What you've seen so far should have familiarized you with how to form Wine commands, how to use Wine prefixes, and how to run applications. So taking what you know, it should be simple for you to now install a game.
Take your physical disk or backup ISO disk image and mount it. Assuming you've set up your Wine prefix to use /media/iso as the D:\ drive, you would do this as follows.
First, create the directory, if necessary, like so:
[codee]sudo mkdir /media/iso
then mount with
sudo mount /dev/dvd /media/iso
sudo mount -o loop /path/to/game.iso /media/iso
Look for the setup file within the disk or image file
If you don't see it immediately, look around the subdirectories until you find it. Once you do you can run it using the wine command. Remember to set your wine prefix.
winetricks is particularly important for newer games. I like to download winetricks into my $HOME/.wine directory. You might choose to keep it in your $prefix directory or somewhere else on your system entirely (perhaps $HOME/bin). winetricks is used to install proprietary DLL files required by some games into Wine.
winetricks is used like any other Wine command. When invoked on its own, it will bring up a GUI list, using $HOME/.wine as its default Wine prefix. You set the Wine prefix exactly the same way as with any other Wine command.
If you get unexpected permission errors make it executable first:
chmod u+x /path/to/winetricks
Unless you add winetricks in your $PATH (not covered) or are currently working in the same directory as the winetricks script, you will need to specify where it is:
Note that I added the argument directx9 to the command this time. winetricks can take arguments to specify which DLL packages to install. I use directx9 because it is the package most often needed when running newer games; winetricks can take multiple arguments. Check the wine app database to find out which dlls are needed to run your games or applications.
NOTE: Do not report bugs about Wine when using winetricks as proprietary DLLs can not be legally supported by the Wine development team.
That just about covers it. Let me know if you find this helpful.