Installing Counter-Strike Source Server On Linux

Abstract:

This article describes fully how to install and launch a counter strike source server (dedicated server) with steam.

Install And Update Steam

To get steam you need to download the hldsupdatetool. This is the official binary, that contains the automatically-updating steam executable. The steam executable itself can be used to install all dedicated game servers, that use the steam platform.

First of all you will need a directory where to put all the server files. Type the following on the server:

mkdir csrds

cd csrds

Then you need to download the executable containing the steam binary. To download the file either use the link below to download it to your local machine,

Steam Executable

or type

wget http://torqzone.com/wp-content/uploads/2008/02/hldsupdatetool.bin

on the server to download directly the the server.

After the download you need to make this file executable, so you can work with it. Type

chmod +x hldsupdatetool.bin

This will present you with a license and you will have to agree with it to continue. If it presents you with an error like this one: ‘uncompress: command not found’

Type this (you have to be root):

ln -s /bin/gunzip /bin/uncompress

After that try executing the hldsupdatetool.bin once more and it should work.

After steam executable is extracted we first need to update it. Execute:

./steam -command update -game “Counter-Strike Source” -dir .

to update steam

Installing the game

To begin the game install you need to repeat the previous command:

./steam -command update -game “Counter-Strike Source” -dir .

Please note, that due to the download it might take some time for all the operations to be completed. On Torqhost servers it usually takes from 5 to 10 minutes for those files to be downloaded. You will see a message saying “HLDS installation up to date” after the install process exists. This shows, that the server is ready for startup.

Starting the server

There are several options you need to know before you start the server. Make sure you understand them before you start any server because it make cause problems if you set them incorrectly.

-autoupdate

This options ensures the server is up to date and generally it should always be used to make sure you installation is up to date.

-game

This is the game you wisth to run on the server. In our case it will be cstrike (because Counter strike source is part of the cstrike series).

+maxplayers

The maximum amount of slots allowed on the server. This is a very important if you are running in a shared environment and are selling servers.

+map

The starting map for the server.

-port

The port number the server will run on. Default is 27015, but if you are running many servers on one machine you will need to change it. Note, that you cannot run multiple servers on a single port.

-ip

The IP address to use. If you want to use an alternate address that comes with the server you can do it by using this switch.

To start the game server type

./srcds_run -game cstrike -autoupdate +maxplayers 20 +map de_dust2 > srcds.log 2>&1 &

Attach other parameters as necessary. This will allow you to close you command line window, but the server will continue running. It basically detaches the server process from any window.

All server executable output will go into the srcds.log file located in the same folder. To view it use

tail srcds.log

or

tail -f srcds.log to view output in real time.

11 Responses to “Installing Counter-Strike Source Server On Linux”

  1. Xikeon NETHERLANDS Says:

    and how do I now stop the server????

  2. admin ESTONIA Says:

    you do something like this:

    ps aux | grep srcds
    from there you will see the process id of the server. Simply type
    kill ID and the server will stop.

  3. death UNITED STATES Says:

    And how do I get it to start when my linux server is booted up without my having to log in and do it manually?

    (Suse 10.3 if it matters)

    your page helped a bunch, Thanks!

  4. admin ESTONIA Says:

    Ok, so what you need to do is add a shell script to the /etc/rc.d/rc3.d/ if you don’t have a GUI or to /etc/rc.d/rc5.d/ if you have a GUI (use runlevel 5) that would launch the servers. Make sure the script is executable by typing chmod +x on the filename.
    The numbers there like S07 for instance show the order in which each service is launched. It is a good idea to start game servers in the end, so make sure you choose the last number.

    You can start the server differently. If you have sudo installed you could use

    sudo -m USERNAME /home/USERNAME/start_script

    if you do not use sudo you could use ssh to swap the user:

    1. Log in as root and type ssh-keygen . When asked for a password leave it blank!
    2. Copy the /root/.ssh/id_rsa.pub file to /home/USERNAME/.ssh/authorized_keys and set permissions appropriately (if you copy as root you would need to chown on the .ssh dir and the authorized_keys file).
    3. Use the following command to start the server in the start script:
    ssh -l USERNAME localhost /home/USERNAME/start_script

    Dennis

  5. BobM UNITED STATES Says:

    I have been looking for this. Thanks for sharing. Worked out well.

  6. Rojer UNITED KINGDOM Says:

    Hi, informative post. Before I start i would like to ask if this would work on a fedora core 6 server

  7. admin ESTONIA Says:

    Yes, this should work on fedora as well.

  8. aditya INDIA Says:

    ok since im new to linux, i have no clue how it works. Though i managed to install steam and run it in the “background”, i didnt understand “Log in as root and type ssh-keygen “. i just dont know how to START playing the game. Like be in the map.

  9. admin ESTONIA Says:

    Well if you started it in the background then you could already connect to the server. SSH keygen has nothing to do with playing really. It is just a convenience feature so that servers would start when the system boots up.

  10. Red00 UNITED STATES Says:

    Hi so installed Suse 10 SP2 server and im following your steps and its not working.

  11. admin ESTONIA Says:

    Hi, what exactly is the error? First try disabling AppArmor and firewall to see if those are the cause. If so re-enable those and configure appropriately. If not let me know what error message you are getting.

Leave a Reply