Keen in Linux

From KeenWiki
Jump to: navigation, search

This page intends to be a complete tutorial on how to setup your Linux system to run Keen and other DOS applications. Therefor the DOS Emulator DOSBox is needed. Some distributions already include DOSBox in their installation media or online package repositories, but most likely it's an outdated version. In this Tutorial there are several ways shown on how to install and configure DOSBox on a Linux based machine (which is either by compiling, by installing via terminal or by installing via a graphical interface).

What you need

DOSBox startup interface.
  • A Linux distribution (DOSBox works fine on both x86 and x64 versions).
  • Any of the Commander Keen games (Originals/Mods).
  • DOSBox itself (either via installing or by downloading the latest source code version at the official website.

If you get the latest version at DOSBox's website, you might need to install additional dependencies/development packages for building it from source code. The pro is you can get some machine-specific optimizations that may or may not improve DOS programs performance. The dependencies for version 0.70 are:

  • GNU C/C++ compilers, GNU Make: provided by most distributions
  • SDL library (+development package, see above): vital for DOSBox.
  • SDL Sound (+development package): ?
  • SDL Image (+development package): ?
  • C/C++ development files

Setting up DOSBox

Note: if you are not building from source code you can skip this section (go to: install DOSBox in RedHat or in Ubuntu/LinuxMint).

Compiling DOSBox

Download DOSBox' source code (should be a tarball named dosbox-X.Y.tar.gz, with X and Y the version numbers) and decompress it in any folder where you have read/write access with your regular user account. You can do it via a graphical user interface tool (such as Ark) or manually from a text Terminal (you'll have to use it anyway):

$ tar -zxvf dosbox-X.Y.tar.gz

That will decompress the package to the current directory. Then, you might want to check the README and INSTALL files provided in the DOSBox source root directory. You'll probably want complete optimizations, so just:

$ ./configure --enable-inline

To generate the makefiles. You can use any switches with configure if you need them, but don't forget to run configure.

$ make

Running make in the same directory the configure script is located at, will start the building process. At the end, assuming everything built successfully, you can do:

$ make install

And everything will install to the target directory provided by you (./configure --prefix=somedir) or the default (/usr/local). If you are installing DOSBox in /usr/local or any other directory where only root can write to, you'll have to

$ sudo make install

instead. If you don't know the root password (i.e., it is not your computer), you might have wanted to use the --prefix switch in the configure call, so that make install is performed in a directory of your user without root privileges. For example:

$ ./configure --enable-inline --prefix=$HOME

Installs DOSBox to your user home directory when doing make install, so the final DOSBox executable should be in $HOME/bin/dosbox.

Installing DOSBox via Terminal

Note: If you followed the steps above (i.e. built the program from its source code) skip this section.


Installing DOSBox RPM package in RedHat via Terminal, you need to have root permissions. Just access the root account and install the RPM:

$ su
$ rpm -i dosbox-X.Y.rpm
$ exit

DOSBox will be installed in the /usr tree.


Installing DOSBox in Ubuntu/LinuxMint via Terminal, you need to have root permissions. Open the Terminal and type:

$ sudo apt-get install dosbox

DOSBox will be installed in the ~/.dosbox tree.

Alternative you can install DOSBox via your Software-Center or Synaptic.

Mounting Keen's directory in DOSBox

Run DOSBox via Terminal by typing:

$ dosbox -c mount C /media/hdaY/somepath

Where -c (etc.) is for automatically mounting /media/hdaY/somepath (real directory) to DOSBox's drive C: (replace the C with any letter you want). After that, assuming you have KEEN.EXE in /media/hdaY/somepath, you just have to enter in DOSBox's command prompt:


Note: mods are getting started by calling their play.bat batch files.

Note: only mount directories which contain 8.3 filenames (8 letters filename, 3 letters extension) to avoid issues with your DOS-based programs.

Creating a shortcut to run Keen in DOSBox

To create a link in order to run a Commander Keen game in DOSBox, two files need to be created (Ubuntu/LinuxMint). One is a Shell-Script which mounts Keen's directory in DOSBox (seen above), the other one is a link for your Dash which calls this script.

Therefore open up your favourite editor (e.g. gedit, Kate, Mousepad, Leafpad) and type:

dosbox some/path/to/KEEN4E.EXE 

The first line tells to execute the file using the shell. The second line calls DOSBox and mounts via the directory parameter the Keen executable into DOSBox. In this case the original KEEN4E.EXE is called. If you are going to link a mod, you might change this to Play.bat or whatever the very batch file is named.

Save this as a Shell-Script with a distinctive name like

To make this script executable open up a terminal and type:

chmod +x /path/to/script/

In a second step you need to create a Dash-link that calls this very script. Again open up an editor and type:

[Desktop Entry]
Name=Keen 4
Comment=DosBox + Commander Keen

Save this file under the path ~/.local/share/applications and name it Keen4.desktop. Now you can open the game in DOSBox by simply typing Keen4 into your Dash.

Configuring DOSBox

Depending on your system specs running Keen might be a straightforward step. However, having problems to run Keen (i.e. it lags, sound does not work, it needs more memory) there is a configuration file included in the ~/.dosbox folder (dosbox.cfg / dosbox.conf). Being a well documented file, you can open it with a text editor of choice and manually edit it to solve your very problem.

Mounting Games folder automatically

You can save yourself some time by having DOSBox automatically mount your folders and change the drive to C:. In original DOS based operating systems a file called AUTOEXEC.BAT contained any commands that the user wanted executed every time the computer booted up. This functionality is simulated by the [autoexec] section of the dosbox.conf file.

Browse into the ~/.dosbox/ folder and open the dosbox.conf. Then scroll down to the very end, and add these lines:

  • Note: ~/OLDGAMES is the path to you Keen games folder.

Alternative Frontend

Alternative you can look for a GUI frontend called DOSBox Game Launcher (DBGL). Simply download this for your Linux version (32-/64-Bit), unpack it and move the extracted folder to /opt/dbgl. Therefor use the Terminal and type:

sudo mv dbgl076_64bit /opt/dbgl

Create a link via the following command:

sudo ln -s /opt/dbgl/dbgl /usr/local/bin/dbgl

Now you can run the program by typing dbgl.

Unlock Cursor

If you want to stop the window from locking your cursor, look up ~/.dosbox/dosbox.conf for how to set autolock=false. If you have games that you need to move your cursor to the edge of the screen, this can be annoying if autolock is off. You can always toggle it on or off using CTRL+F10.

Full Screen

Just press ALT+ENTER to go into and out of full screen. Alternatively, you can open the ~/.dosbox/dosbox.conf file as mentioned above and change fullscreen=false to fullscreen=true. DOSBox will then run in full screen mode when you open it.


These are the default keybindings. They can be changed using the keymapper. Therefore open DosBox, press CTRL+F1 (or run it via Terminal: dosbox -startmapper). Then map the keys to your liking.

DOSBox KeyMapper interface.
Key Action
ALT-ENTER Switch to full-screen (and back).
ALT-PAUSE (ALT-F16 on OS X) Pause emulation.
CTRL-F1 Show the keymapper configuration screen,
CTRL-F4 Update cached information about mounted drives. Useful if you changed something on a mounted drive outside of DOSBox. Also cycles through disk images mounted using IMGMOUNT.
CTRL-F5 Save a screenshot (goes to ~/.dosbox/capture/ folder).
CTRL-ALT-F5 Start/Stop recording of AVI video. Attention: You may well have some problems with this, please see head to X-Server interception for more information.
CTRL-F6 Start/Stop recording sound output to a wave file (goes to ~/.dosbox/capture/ folder).
CTRL-ALT-F7 Start/Stop recording of OPL commands.
CTRL-ALT-F8 Start/Stop the recording of raw MIDI commands.
CTRL-F7 Decreases frameskip.
CTRL-F8 Increases frameskip.
CTRL-F9 Kill (close) DOSBox.
CTRL-F10 Capture/Release the mouse (if you need to use the mouse within DOSBox).
CTRL-F11 Decrease DOSBox cycles slows down the emulation).
CTRL-F12 Increase DOSBox cycles speeds up the emulation).
ALT-F12 Unlock speed (turbo button).

These default bindings are also documented in the README file accompanying the software.

X-Server interception

Attention: by default, DOSBox’ video capturing feature is triggered by pressing CTRL+ALT+F1 simultaneously. Unfortunately this key combination will never reach DOSBox, as it will typically get intercepted by the X-Server and drop you to the 5th text console instead. It is recommended to change the combination for the video capturing, like mentioned above.

Upscale Video Recordings

By default the video recorded output solution in pixel is 320x200. To upscale and transcode this, there are many different ways to do so, like to pick a tool of choice (for eg. VirtualDub or Handbrake).

Upscale via Script

But to customize the parameters more precise for your own needs plus keeping the output pixel perfect without any artifacts, an alternative way has to be chosen. This could be done by using a few Terminal commands.

First, get the FFmpeg codec from the official packages or type:

sudo apt-get install ffmpeg && sudo apt-get install libavcodec-extra

Next type into your terminal the following command:

ffmpeg -i in.avi -sws_flags neighbor+full_chroma_inp -s 1280x800 -r 30 -vcodec libx264 -crf 20 -acodec libmp3lame -aq 2 -f mp4 out.mp4

Change the parameter in.avi to the path where DOSBox saves its video recordings, by default this is ~/.dosbox/capture/keen4e_001.avi . Also change the parameter out.mp4 to the a path of your choice (for eg. ~/myvideos/nameoftheoutputfile.mp4). You can freely set the solution (here 1280x800). But it is recommended to use multiples of 320x200 (for eg. 640x400, 960x600, 1280x800...). Additionally you can chose the output container format. Here it is mp4 (alternatives: avi, mkv...).

Finally run the command and wait until everything is done. This might take some time, depending on the source size and your system specs.


Parameters Action
in.avi name and path of the source video you recorded with DOSBox
out.mp4 name and path of the output video destination
mp4 name of upscaled and muxed output container.
1280x800 the output solution in pixel. Multiples of 320x200 (for eg. 640x400, 960x600, 1280x800...)
sws_flags controls the software scale
neighbor+full_chroma_inp lets the scaler perform nearest neighbor interpolation and forces it to take the full input chroma resolution into account
-r 30 output frame rate
-vcodec libx264 determines the video encoder
-acodec libmp3lame -aq 2 codec for a variable bitrate mp3 stream
-aspect 4:3 set up a custom display aspect ratio to scale the video uniformly

External Links

See also

DOSBox Tutorial (Windows)