How to Host a Left 4 Dead 2 Server on Linux (Ubuntu)

In this tutorial, I’m using a dedicated server running Ubuntu to host a Left 4 Dead 2 server. These instructions will also work for the first Left 4 Dead.

Install the necessary packages.

sudo apt-get update
sudo apt-get install lib32gcc1 screen wget

Create a directory for the L4D2 server.

mkdir ~/l4d2 ; cd ~/l4d2

Retrieve and extract SteamCMD.

tar -xvzf steamcmd_linux.tar.gz

Run SteamCMD.


The program will update itself and you’ll be brought to a Steam prompt. You’ll have to login with a Steam account that has purchased L4D2 in order to proceed. ┬áIt seems that you can now login anonymously.

login <username> <password>
login anonymous

It should then prompt you for a Steam guard code, so enter that. Next, set the installation directory and let SteamCMD start downloading all of the necessary files. (Make sure you specify an absolute path)

force_install_dir /home/<user>/l4d2/game/
app_update 222860 validate

That part will take a while. After it’s complete, you’re ready to run your server. To install L4D instead, use 222840.


But there are a few things you should do first.

1. Create a server.cfg file

vi ~/l4d2/game/left4dead2/cfg/server.cfg

I only bother configuring a few settings, and leave all other cvars at their default values.

hostname "sample hostname"
rcon_password "samplepassword"

Some resources to check out for more in-depth server.cfg editing:

2. Decide what kind of variables you want to pass to srcds_run.

For example:

~/l4d2/game/srcds_run +ip -port 27015 +map c1m4_atrium -secure

More information here:

I just put that code above into a script and then execute it inside of a screen session, disconnect from the screen, and start playing.

screen -S l4d2 ~/

Ctrl + A, D to disconnect from screen.

Connecting to your server

You can open the developer console and connect to your server via IP address with this command:

connect x.x.x.x

Alternatively, you can create a lobby and configure your game to only try connecting to your server when you click “Start game.”

mm_dedicated_force_servers x.x.x.x:27015

Only problem is, every time you boot up L4D2 and want to connect to your server, you’ll need to remember that command and your IP address. To avoid that, put the command in a .cfg file and store it here:

C:\Program Files (x86)\Steam\SteamApps\common\left 4 dead 2\left4dead2\cfg\myserver.cfg

When in game, just execute your cfg file and you’re good to go.

exec myserver.cfg

Remember to forward port 27015 on your router.