HowTo: Setup a Left4Dead Dedicated Server on Linux

This tutorial explains how to setup a Left4Dead (L4D from hereon) dedicated server on Linux. Aside from the actual config settings, this process can be used to install any of the Steam games listed here. For this tutorial I will be using Fedora 8 x64, however the process is the same for all distributions.

L4D Title ScreenContents

1. Before You Start
1.1. The Uncompress Command
2. Server Installation
2.1. The HL Dedicated Server Update Tool
2.2. Installing the Game Server
3. Configuring the Left4Dead Server
3.1. Creating the server.cfg File
3.2. Starting the Server
3.3. Using Screen to Run the Server
3.3.1. Installing Screen and the Basics
3.3.2. Launching the Server at Startup
4. Appendix
4.1. Game Options for Steam
4.1.1. For Source Games
4.1.2. For HL1 Games
4.1.3. For 3rd Party Games
4.2. Creating a Steam Group

1. Before You Start

While you can install the L4D server into any user account/directory, it is recommended to create a dedicated user to run the server under.

To create a new user and set the password, as root enter the commands:

$ useradd hlserver
$ passwd hlserver

And switch to the new account with 'su':

$ su - hlserver

You now have a clean user base to install the server, without interfering with any other users/system files.

1.1. The Uncompress Command

The uncompress tool is simply gunzip, which should be installed on pretty much every distribution out there. Not all distributions symlink this file and this can cause problems later.

Make sure the file /usr/bin/uncompress exists. If it doesn't, login as root and symlink it with the following command, you will need it to continue with this tutorial.

$ ln -s /bin/gunzip /usr/bin/uncompress

2. Server Installation

The following sections explain how to download and install the L4D server.

2.1. The HL Dedicated Server Update Tool

The first order of business it to download the Half Life Dedicated Server Update Tool. This will give you what is basically a console Steam application, that will allow you to download each of the game servers, in this case L4D, but it can be used for any of the games listed here.

To download the hlupdatetool, enter the following command:

$ wget http://www.steampowered.com/download/hldsupdatetool.bin

Make the file executable with:

$ chmod u+x hldsupdatetool.bin

Finally, run the program to download Steam:

$ ./hldsupdatetool.bin

If at this point you receive an error saying that it cannot find uncompress, see here (skipping sections, tut tut tut).

2.2. Installing the Game Server

In order to host a L4D server, obviously you need the L4D maps and game files. Steam is brilliant for this, simply enter the command below to start downloading the L4D server, this will take about an hour on a 4-8Mb/s Internet connection.

Enter the following command:

$ ./steam -command update -game l4d_full -username <username> -password <password>

When the application launches, it states that the username and password are no longer required. As I'd already entered them, that is how I proceeded, and recommend you do the same.

If you want to setup a server for something other than L4D, replace the '-game l4d_full' with the game you want to install, the names can be found here.

If you are setting up a server other than L4D, this is as far as this tutorial can take you, from this point on I will be discussing the L4D specific setup, I recommend you head over to Google and search for a specific tutorial for the game you are installing.

3. Configuring the Left4Dead Server

At this point, you should be able to start your L4D server with the command:

$ ./srcds_run -console -game left4dead +map l4d_hospital01_apartment.bsp

It should start a default server and you should be able to see it in Steam under LAN (if you're on a LAN), if not add the IP address. Once you've confirmed the server runs without error, exit it (type 'quit') and let's get on with the config.

If you can't see it in Steam, but do get a 'VAC Secured Mode Enabled' message on the server console, the server is working.

3.1. Creating the server.cfg File

L4D doesn't seem to include a default configuration file, so we'll start by creating that.

$ touch left4dead/cfg/server.cfg

Open the server.cfg file in your favourite editor, as a minimum, you'll want the following:

hostname "Server Name"
//sv_password "secret" // Password to connect to the server (optional, may not work for group servers etc)
rcon_password "secret"
mp_disable_autokick 1

sv_allow_wait_command 0
sv_alltalk 0 // Only allow team voice
sv_alternateticks 0 // If set, the server only simulates entities on even numbered ticks
sv_clearhinthistory 0 // Clear memory of server side hints displayed to the player
sv_consistency 1 // When set, server enforces file consistency for critical files
sv_contact "you@domain.com"
sv_downloadurl "" // URL for clients to download missing files

sv_lan 0 // Server is a lan server (no auth, no heartbeat, no non-class C IPs)
sv_region 3 // Region codes: 0 - US East coast, 1 - US West Coast, 2 - South America, 3 - Europe, 4 - Asia, 5 - Australia, 6 - Middle East, 7 - Africa, 255 - World

sv_log_onefile 0 // Single log file
sv_logbans 1 // Log server bans
sv_logecho 0 // Echo log information to the console
sv_logfile 1 // Log server info
sv_logflush 0 // Write the log after each change
sv_logsdir "logs" // directory to save server logs

// sv_maxcmdrate 100 // (If sv_mincmdrate is > 0) this sets the maximum value for cl_cmdrate
// sv_steamgroup // the groups steam group ID, allows members to join from the main menu add
// sv_steamgroup_exclusive 1 // make it a private server (see Appendix 4.2)

If you want to be able to connect directly to your server without using the lobby, i.e. by typing 'connect ip:port' in the game's console, or from any of the Steam dialogs, then you need to add the line below to the config, otherwise you'll receive an error: Reservation cookie some_random_number: reason ReplyReservationRequest

sv_allow_lobby_connect_only 0

3.2. Starting the Server

Once you've got your setup how you want, you can restart your server with the following command, this is the same, but extended version of what you used above.

$ ./srcds_run -console -game left4dead +ip "192.168.0.10" +hostport 27015 +map l4d_hospital01_apartment.bsp

That's it! Your server is setup and ready to be played on. The remainder of the tutorial explains how to get your server running inside screen for easier access, and getting it to load at bootup.

3.3. Using Screen to Run the Server

Screen basically lets you run multiple programs (screens) in a terminal, it's kind of like virtual desktops for the console. By using screen, you can start your L4D server, and leave it running inside screen, and reconnect back to it later to perform maintenance. Using screen, you can also get your server to launch automatically when your system starts, and still have access to it's console.

This section is Fedora specific, but should apply to any RPM based distribution. If you are using an APT based distribution, either adapt the commands or seek help on your distributions forums. (If anyone would like to send me the APT command equivalents, I'll happily add them to the tutorial).

This section will explain how to install screen, launch it normally, and set it to launch automatically at system startup. This is only a basic screen tutorial, covering the essentials of what is needed to achieve our goal, if you would like a more comprehensive screen tutorial, try this one.

3.3.1. Installing Screen and the Basics

On Fedora 8 screen wasn't installed with the default installation. To install screen, run the Yum command:

$ yum -y install screen

To start screen, simply type 'screen', this will start a new screen session. You can create more windows within the session by pressing Ctrl+A followed by C. To detach from the session and leave it running, press Ctrl+A followed by D. To return to the session, you would type 'screen -r' to restore the detached session.

To rotate between windows within screen, use Ctrl+A followed by N for next, and Ctrl+A followed by P for previous.

3.3.2. Launching the Server at Startup

To make things easier, we'll create a separate script to call from rc.local, create a script similar to the following, making sure to adjust any paths that may be different.

#!/bin/sh
cd /home/hlserver
screen -m -d -S l4d ./srcds_run -console -game left4dead +ip "192.168.0.10" +hostport 27015 +map l4d_hospital01_apartment.bsp

A quick explanation of the parameters passed to screen:

-d
Tells screen to load in a detached mode, this is equivalent to manually starting screen, and then pressing Ctrl+A, D.

-m
Ensures that a new screen session is created.

-S l4d
Gives the session a meaningful name, which will be displayed when using 'screen -list' or 'screen -r'.

Make the script executable with:

$ chmod u+x filename.sh

Finally, add the full path to the new script to /etc/rc.local.

4. Appendix

4.1 Game Options for Steam

When installing a game on using Steam, as is explained in section 2.2 Installing the Game Server, you can install any of the games using the names below. Speech marks are needed if the name contains a space.

4.1.1. For Source Games:

4.1.2. For HL1 Games:

4.1.3. For 3rd Party Games:

4.2. Creating a Steam Group

To create a Steam Group, head on over to http://steamcommunity.com and login. Click on 'My Control Panel' at the top and in the groups section, click the 'Create a new group' link. Give it a name and abbreviation and create the group.

You can make the group private or public. A private group will require you to invite your friends. This can be done by right-clicking them in the Friends list in the main Steam application, clicking 'Invite to Group' followed by the group you have just created. You may need to sign out and back into Friends for the group to show in the menu.

The GroupID needed for the 'sv_steamgroup' option is shown on the Admin page.