Do you want to try some good-old MS-DOS games and defunct C++ compilers like Turbo C++ in Linux? Good! This tutorial will teach you how to run MS-DOS games and programs in Linux using DOSBox.
What Is Dosbox?
Dosbox is an x86 PC DOS-emulator that can be used to run classic DOS games or programs. DOSBox emulates an Intel x86 PC with sound, graphics, mouse, joystick, and modem etc., that allows you to run many old MS-DOS games and programs that cannot be run on modern operating systems, such as Windows XP and later, Linux and FreeBSD.
Dosbox is free, written using C++ programming language and distributed under GPL.
Install DOSBox In Linux
DOSBox is available in the default repositories of most Linux distributions.
Install Dosbox in Alpine Linux:
$ sudo apk add dosbox
On Arch Linux and its variants like Manjaro Linux, run:
$ sudo pacman -S dosbox
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install dosbox
$ sudo dnf install dosbox
$ sudo zypper install dosbox
There is no initial configuration required to use DOSBox and it just works out of the box. The default configuration file named dosbox-x.xx.conf exists in your ~/.dosbox folder.
In this configuration file, you can edit/modify various settings, such as starting DOSBox in fullscreen mode, use double buffering in fullscreen, set preferred resolution to use for fullscreen, mouse sensitivity, enable or disable sound, speaker, joystick and a lot more.
As I mentioned earlier, the default settings will work just fine. You need not to make any changes.
DOSBox Basic Usage
To launch DOSBox, run the following command from the Terminal:
This is how DOSBox interface looks like.
As you can see, DOSBox comes with its own DOS-like command prompt with a virtual
Z:\ Drive. So if you're familiar with MS-DOS, you wouldn't find any difficulties when working in DOSBox environment.
Here is the output of
dir command (Equivalent of
ls command in Linux) output:
If you're a new user and it is the first time you use DOSBox, you can view the short introduction about DOSBox by entering the following command in DOSBox prompt:
Press ENTER to go through next page of the introduction section.
To view the list of most often used commands in DOS, use this command:
To view list of all supported commands in DOSBox, type:
Remember, these commands should be used in the DOSBox prompt, not in your Linux Terminal.
DOSBox also supports a good set of keyboard bindings. Here is the default keyboard shortcuts to effectively use DOSBox.
To exit from DOSBox, simply type and hit ENTER:
By default, DOSBox starts with a normal window-sized screen like above. To start dosbox directly in full-screen window, edit your
dosbox-x.xx.conf file and set the value of
fullscreen variable as
enable. Now, DosBox will start in full-screen mode. To go back to normal screen, press
Hope you learned the basic usage of DOSBox.
Let us go ahead and install some DOS programs and games.
Run MS-DOS Games And Programs In Linux Using DOSBox
First, we need to create directories to save the programs and games in our Linux system.
I am going to create two directories named
~/dosgames. The first directory is for storing programs and latter for storing games.
$ mkdir ~/dosprograms ~/dosgames
For the purpose of this guide, let me show you how to install Turbo C++ program and Mario game.
First, we will see how to install Turbo C++ compiler.
Download the latest Turbo C++ compiler, extract it and save the contents file in
~/dosprograms directory. I have save the contents turbo c++ in my
$ ls dosprograms/tc/ BGI BIN CLASSLIB DOC EXAMPLES FILELIST.DOC INCLUDE LIB README README.COM
And mount the
~/dosprograms directory as virtual drive
C:\ in DOSBox.
Z:\>mount c ~/dosprograms
You will see an output something like below.
Drive C is mounted as local directory
Now, change to the
C drive using command:
And then, switch to
Finally, run turbo c++ executable file:
Note: Just type first few letters and hit ENTER to autocomplete the file name.
You will now be in Turbo C++ console.
Create new file (
ATL+F) and start coding:
Similarly, you can install and run other classic DOS programs.
You might be encountered with following error while running turbo c++ or any other dos programs:
DOSBox switched to max cycles, because of the setting: cycles=auto. If the game runs too fast try a fixed cycles amount in DOSBox's options. Exit to error: DRC64:Unhandled memory reference
To fix this, edit your ~/.dosbox/dosbox-x.xx.conf file:
$ nano ~/.dosbox/dosbox-0.74.conf
Find the following variable and change its value from:
Save and close the file. Now you can be able to run the dos programs without any problems.
Now, let us see how to run a dos-based game, for example Mario Bros VGA.
Download Mario game from here and extract the contents in
~/dosgames directory in your Linux machine.
We have used virtual drive c: for dos programs. For games, let us use
d: as virtual drive.
At the DOSBox prompt, run the following command to mount
~/dosgames directory as virtual drive
Z:\>mount d ~/dosgames
And then go to mario game directory and run the
mario.exe file to launch the game.
Start playing the game:
Similarly, you can run any dos-based games as described above. You can view the complete list of supported games that can be run using DOSBox here.
DOSBOX is not a complete replacement for MS-DOS and it lacks many of the features found in MS-DOS. However, it is just enough to install and run most DOS games and programs.
For more details, refer the official DOSBox manual.