HLDS Guides for Newbies
Created by Vadakill

This guide will walk you through the steam tool for updating your server, downloading the core files and then extracting and configuring your Natural Selection server for basic operation.

For better or for worse steam is here and is here to stay. Once the WON servers go down for good there will be no other way to authenticate Half-life, Counter-Strike and Day of Defeat Retail users to play on your servers. As you may or may not know the auth server is important for two main reasons. First, it allows you to ban users who are disruptive to your environment, second when Valve Anti-Cheat (VAC) becomes available for NS it will allow you to use the updated modules to help fight cheating.

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 Half-Life Dedicated Server with only "user" permissions you limit the damage that could potentially be done to your server and file systems other than the ones owned by that specific user. 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
ns_dedicated_server_v3.zip (136 MB) - Location: Check http://www.unknownworlds.com/ns for download mirrors
ns_dedicated_server_patch_v305.zip (~2.5 MB) - Location: http://download.jarhedz.com/ns_beta/direct/ns_dedicated_server_patch_v305.zip
Setting Up a Directory Structure and Extracting the Base Server File

Now that you have all the files in your home directory needed 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 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. (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).

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

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

Now we'll need to update the steam tool to the latest version, see the next section:
Updating the steam updater

As of 03/10/05 you no longer need to create an account for your Half-Life dedicated server. So we no longer need to do that portion of the setup. However we still need to update all the tools and server files to the latest versions to ensure success. First thing's first, updating the HldsUpdateTool:
Code ./steam -update

When it's done it may give you a "WARNING!" message that the command is deprecated. Just hit the Enter/return key on your keyboard to get the command line prompt back.

The steam updater tool should be ready to go, go to the next section to learn how to download the latest base server files.
Downloading, Extracting and Updating HLDS and NS

Next we will need to actually get the HLDS core files needed to run the server.
Code ./steam -command update -game valve -dir /home/hlds/hlds_l

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)

Now that you've downloaded the NS server file and created a directory to store them you should move the NS server file into your hlds_l directory and extract it. (NOTE: Do NOT use "unzip -a" to extract the NS 3.0 server files):
Code cp ../ns_dedicated_server_v3.zip .
unzip ns_dedicated_server_v3.zip

...then remove the .zip archive since it's taking up space and we won't need it anymore:
Code rm ns_dedicated_server_v3.zip

Next we need to patch the dedicated server with the appropriate 3.05 update:
Code cp ../ns_dedicated_server_patch_v305.zip ns
cd ns
unzip ns_dedicated_server_patch_v305.zip

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

You should now edit the server.cfg file and replace the default hostname with one you want such as "Bobo's Love shack" or whatever. Vi can be difficult to use at first but you will quickly get used to it. Some simple commands 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!"
To edit your server.cfg file, change to your "ns" directory then do:
Code vi server.cfg

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

You should be able to start your server after this. Change directory back to you hlds_l directory and then type:
Code ./hlds_run -game ns +exec server.cfg +ip xxx.xxx.xxx.xxx +maxplayers 12 +map ns_eclipse

If the server starts you should then be able to type "stat" 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 hlds server process will stop. 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 hlds server using screen you would run the following command:
Code screen -A -m -d -S ns ./hlds_run -game ns +ip xxx.xxx.xxx.xxx +maxplayers 12 +map ns_eclipse

You can then attach the screen by typing "screen -x ns" 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