In this tutorial, I’m using a dedicated server running Ubuntu to host a Counter-Strike 1.6 server.
Install the necessary packages.
sudo apt-get update
sudo apt-get install lib32gcc1 screen wget
Create a directory for the CS 1.6 server.
mkdir ~/cs16 ; cd ~/cs16
Retrieve and extract SteamCMD.
tar -xvzf steamcmd_linux.tar.gz
The program will update itself and you’ll be brought to a Steam prompt. Login anonymously.
Next, set the installation directory and let SteamCMD start downloading all of the necessary files. (Make sure you specify an absolute path)
app_update "90 -beta Beta" validate
That part will take a while. After it’s complete, you’re ready to run your server.
But there are a few things you should do first.
1. Create/edit a server.cfg file
I only bother configuring a few settings, and leave all other cvars at their default values.
hostname "sample hostname"
2. Decide what kind of variables you want to pass to hlds_run.
~/cs16/game/hlds_run -game cstrike -autoupdate -pingboost 2 -port 27016 +maxplayers 20 +map de_dust2
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 cs16 ~/start-server.sh
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:
Remember to forward the port on your router (27015 by default, or whatever you specified in the hlds_run command as shown above).
You may get an error like this if you try to launch the server from some directory other than where it’s installed:
Invalid game type 'cstrike' sepecified.
Thu May 1 23:34:01 EDT 2014: Server Failed
It makes no sense. At all. But, you have to launch the server from the game directory itself. In short, make sure you have a
cd command before your hlds_run line in your script. For example:
./hlds_run -game cstrike -autoupdate -pingboost 2 -port 27016 +maxplayers 20 +map de_dust2