HLDS Guides for Newbies
Created by Vadakill
 
Introduction

This guide will walk you through creating a steam account for your server, downloading the core files and then extracting and configuring your HL2MP installation for basic operation.

Once I'm done installing my Linux box and securing it I usually never log into the console again. It sits in a corner with no monitor, no keyboard and has only two wires coming from it, the power cord and an Ethernet cable. All administration on my Linux server is done through SSH using the putty client found here:

PuTTY: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

You'll want to set up putty on your windows machine and make sure you can log into your Linux box using SSH. This way you can always get to it from where ever you may be. If you are behind a DSL/Cable router you'll need to forward port 22 to your Linux box to reach it from the outside.

Most people will have a user account that they will be setting the server up under. It is not a good idea to be running an hlds server as "root", just to be safe. A user account is usually something like "/export/home/username" or "/home/username"; in any case I will be referring to this place as your "home directory". If you don't have a basic username to run under or you only know how to run as root read the next section "Preparing for Install" to learn how to create a username for yourself to use.
 
Preparing for Install

It's never a good idea to run any service that receives information from the Internet as the "root" user. Root has permission to modify, move, change or delete anything on the system. Because of this, you really only want to use root to make sweeping, system wide changes, that's why we want to run our server as a "user". By running a HL2MP server as a "user" you limit the damage that could potentially be done to files which that user is given permission to modify. So how do you create a user for our Half-Life server?

Simple, chances are if you are looking at this guide that you already have a user account. A user account is basically any account other then "root". If you have "root" access to your server and would like to know how to create a new user account for your server, read on. If you have a user account already that you'd like to use, skip on to the next section "Downloading the Proper Files" but keep in mind the guide is set up with the idea that your user account is "hlds"; you'll have to make substitutions as necessary to fit your setup.

Okay, to create a new user account you need to be logged in as root. Once that is done, type the following command:
 
Code useradd -m hlds

That will create a user by the name of "hlds" on your system as well as create a "home directory" that the user has permission to save files to. Having established the user account is good, but we need to be able to log in as this user, so we will set a password for it. Using this command you can set passwords for new accounts as well as re-use the command to change passwords. Here's the command:
 
Code passwd hlds

The password tool will then ask you to enter the "New Password:", you should choose to enter something 6 to 8 characters in length with a combination of letters and numbers. For example, "applepie" is not a good password but "4ppl3p13" or "appl3pi3" is. Use something that is hard to guess, better yet, choose a phrase or quote you like and take the first letters from each word or substitute numbers for letters. For example: "An Apple A Day Keeps The Doctor Away" becomes "aaadktda" or "444ktd4"

Once the password has been changed you should see a message about "All tokens updated". You should now be ready to move on to the next section. Log out from root by typing "exit" or CTRL+D and log in as your new "hlds" user.
 
Downloading the Proper Files

First thing you should do make sure your logged in as your user account, not as root, and you are in your home directory. You'll want to download the server files onto your machine so that they can be extracted and set up. You can download via FTP or HTTP by using lynx, elinks or wget, it doesn't really matter. How I usually do things is, I use my windows PC to copy URL and then go to my putty client, type "wget" and then right-mouse-click to paste the URL; once you hit enter it should then download the file. wget will save the file to whatever location you are currently in when you started it, keep this in mind.

Make sure you are logged in as your user account and in your home directory, then download the following file using lynx, elinks or wget:
 
hldsupdatetool.bin (2.84 MB) - Location: ftp://hlserver:hlserver@ftp.valvesoftware.com/linux/hldsupdatetool.bin

 
Setting Up a Directory Structure and Downloading the Basic Server Files


Now that you have the file you need in your home directory for the install we need to go through setting up the directory structure and extracting the files in the proper locations.

First, we need to extract the steam binary so we can get on with the core Half-Life 2 Source Dedicated Server (HLDS) installation. To do this we'll need to issue a few commands to get the .bin(ary) file into a form where we can run it. We'll change the mode of the file to an executable by issuing the following command:
 
Code chmod 755 hldsupdatetool.bin

Now we need to run the file:
 
Code ./hldsupdatetool.bin

This will give you a license agreements screen. Type "yes" and hit enter to agree to the license and extract the steam file.

Good, once that's done we need to prepare a directory to store the HLDS files that we will be downloading in a few minutes. (NOTE: If you get a Message "sh: line 1: uncompress: command not found, Broken pipe" see trouble shooting section at the end of this guide)

So now we're going to make a place to download all the steam files needed for the core HLDS server. I like the naming convention of srcds_l for my storage directory. That is what I'm used to so that's what I created.
 
Code mkdir srcds_l

Next, we change into the srcds_l directory and copy the "steam" file to it.
 
Code cd srcds_l
mv ../steam .

Now we'll need to create a steam account for the server, see the next section:

 
Setting up a Linux Steam Account

Just like for the client, you will need to create an account for your server. It's not too difficult as long as you pay close attention to how the command line is formed. Before you update your game however, you need to run the steam file once on it's own to get it to update itself to the latest version.
 
Code ./steam -update


The method for creating an account is a little elaborate and requires a bit of typing. For this example I'm going to use "server@vadakill.com" as my Steam username (needs to be unique, that's why e-mail addresses are good), setting "admin@vadakill.com" for my E-mail address and "myPa$$w0rd" will be my Steam password. The -question and -answer are there so you can recover your password if you should ever forget it. Here's how I would create an account with this method:
 
Code ./steam -command create -username server@vadakill.com -email admin@vadakill.com -password myPa$$w0rd -question "My dog's name is?" -answer woofy


If everything goes well it should say "Account Created Successfully".
 
Downloading and Updating HL2MP

Next we will need to actually get the core HL2MP Source files needed to run the server.
 
Code ./steam -command update -game hl2mp -dir /home/hlds/srcds_l -username server@vadakill.com -password myPa$$w0rd -remember_password

This could take 15 minutes or several hours depending on how much bandwidth you have and how busy the steam content servers are. Doing it this way ensures that you have the latest, most up-to-date server files. (NOTE: If you get a message that contains "ContentServer rejected client's protocol version", please check the trouble shooting section at the end of the guide for a fix)

That should do it! The basics are all taken care of, now you just need to do a little custom configuration.
 
Custom Configuration

The default HL2MP server does not come with a server.cfg file that you can use as a base for custom configuration so you will need to create one. You'll need to move into your cfg directory in the HL2MP directory in order to create a file that will work.
 
Code cd /home/hlds/srcds_l/hl2mp/cfg
touch server.cfg

To do the editing we will be using a Unix text editor called "vi". Vi can be a confusing at first, but you will quickly get used to it. Here are some simple vi commands, use it as a reference to get you started:
  • To escape or turning off any mode you are in you can just hit the ESC key twice.
  • To begin typing information press the "i" key until an "--insert--" appears near the bottom of the screen. Hit ESC to get out of this mode.
  • To delete a single line make sure your out of any other mode by hitting "ESC" and then type "dd"
  • To delete 10 lines, make sure your out of any other mode by hitting ESC and then type "d10d"
  • To go to the beginning of your file type "gg", to go to the end hold down SHIFT GG
  • To go to a specific line do SHIFT G, the line number then SHIFT G again.
  • To save your file and quit vi do, SHIFT ZZ
  • To undo the last mistake you made do ":u"
  • If you made a lot major mistakes and you want to quit without saving your file, do ":q!"

We need to edit the empty server.cfg file and put some server variables in it:
 
Code vi server.cfg

Here is a basic server.cfg file you can use to start you off. Just copy this info off the page here, switch back to your server console, press "i" on your keyboard to turn on insert mode and then right click to paste the contents.
 
Code hostname "Vadakill's HL2MP"

rcon_password "jibberjabber1"

// Logging
//log on

// Gameplay

mp_flashlight 1
mp_fraglimit 100
mp_timelimit 45
mp_falldamage 10
mp_teamplay 0

// Server Cvars

sv_lan 0
sv_region 1
sv_allowupload 0
sv_allowdownload 1
sv_alltalk 1
sv_maxrate 7000
sv_minrate 2000
sv_maxupdaterate 30
sv_minupdaterate 10
sv_hltv 0

fps_max 100
mapcyclefile mapcycle.txt

You should the replace the default hostname with one you want such as "Bobo's Love shack" or whatever. Also, make sure you replace "jibberjabber1" with an rcon password you'd like to use.

After you are done editing your server.cfg file, press SHIFT ZZ to save and close the file.

You should be able to start your server after this. Change directory back to you srcds_l directory:
 
Code cd /home/hlds/srcds_l

and then type:
 
Code ./srcds_run -game hl2mp -ip xxx.xxx.xxx.xxx +maxplayers 12 +map dm_lockdown

(NOTE: "-ip xxx.xxx.xxx.xxx" is the publicly accessible IP address your server is associated with. My server's IP is "208.28.184.222" so I would enter "-ip 208.28.184.222" in the command line)

If the server starts you should then be able to type "status" in the console and it should feedback to you some server statistics like, map, players, server build, etc...

This is all well and good but as soon as you close your console the hl2mp server process will shut down. So how to we prevent this? Many admins don't like screen, but I use it. Screen allows you to start a virtual console, and then view it (attach) and hide it (detach) at your choosing. To start an hl2mp server using screen you would run the following command:
 
Code screen -A -m -d -S mp ./srcds_run -game hl2mp -ip xxx.xxx.xxx.xxx +maxplayers 12 +map dm_lockdown

You can then attach the screen by typing "screen -x mp" and hitting enter. You should now be able to see the server output. To detach the screen and have it go back to running in the background you would hold "CTRL" then press "a", then release "CTRL" and hit "d" to detach.

 
Trouble Shooting

This is a list of common error messages that have been seen while trying to setup or update a steam server:
 
Error Message: Enter 'yes' to accept this agreement, 'no' to decline: yes
sh: line 1: uncompress: command not found
Broken pipe

This one is pretty common. This occurs if the command "uncompress" is not found in it's default location or the uncompress command on your server is called something else. This error is usually fixed by running the following command as root.
 
Code ln -s /usr/bin/gunzip /usr/bin/uncompress

--------------

 
Error Message: Checking bootstrapper version ...
Updating Installation
No installation record found at /home/hlds/hlds_l
Updating 'Linux Server Engine' from version 0 to version 6
ContentServer rejected client's protocol version

This Error usually only occurs when there has been a previous steam server on the system but the administrator removed it and wanted to start from scratch. Steam places a hidden folder in the user's home directory called ".steam". The "." in front of the "steam" folder tells the file system that this is a hidden file to prevent accidental deletion. If you are starting from scratch you can wipe this directory out safely. To do this you can run the following command as the user you typically run your server under:
 
Code rm -rf ~/.steam