Setting up a Counter-Strike 1.5 server under Linux

I myself run a couple of servers on Debian and Redhat Linux machines. Personally I prefer the Debian distribution above the Redhat distribution due to the stability of it.

But nevertheless the Redhat machine also works perfect for me.

I assume you already downloaded all the necessary files I mentioned in the server part of this site, so I'll start right away.

The following instructions are the same as I installed my Counter-Strike servers. You can choose your own path/install dir. They do NOT have to be the same as the ones listed below.

When you SHH to your Linux machine your prompt (all commands should take place from the prompt) probably will look something like this:

login@server:/var/home/login$

From this prompt on we will do the following :

1.  cd /usr/local/games
2.  mkdir halflife
3.  cd halflife
4.  chmod +x hlds_l_3110_full.bin
5.  ./hlds_l_3110_full.bin

Bla bla bla yada yada yada ...

agreement, either oral or written, and any other communications between
Valve and you regarding the subject matter hereof.

Enter 'yes' to accept this agreement, 'no' to decline: yes

extracting hlds_l_3110_full.tar.gz...done

When you have accepted the Valve agreement, the hlds_l_3110_full.bin file will change to hlds_l_3110_full.tar.gz

We'll continue doing the following :

6.  tar zxvf hlds_l_3110_full.tar.gz
7.  cd hlds_l

When the file is extracted completely, you have a fully functional Linux Half-Life dedicated server installation ready.

We'll move on to the Counter-Strike installation next.

Copy or download the Counter-Strike Full Linux Server file to the hlds_l directory (where the HL server is installed after the extraction).

8.  tar zxvf cs_15_full.tar.gz

And voila! You've now installed the latest Half-Life dedicated server and installed the latest Counter-Strike release. You can finetune
your motd.txt (welcome text when entering the server) and your server.cfg in your /hlds_l/cstrike/ directory, using vi or pico.

The easiest way to keep your server up and running, is to use screen. Screen is an application that is part of the default distribution
of many types of Linux. It allows you to create virtual terminal screens which can be detached and run in the background, then re-attached
and brought to the foreground at will. In MS-Windows terms, think of it like minimizing a window. It's still there and running, you just aren't
looking at it on your desktop.

Now let's get started ...

9.  cd /usr/local/games/halflife/hlds_l

10. screen

11. export LD_LIBRARY_PATH=/halflife/hlds_l:$LD_LIBRARY_PATH

What the above does is tells Linux to look in the /halflife/hlds_l directory for dynamic libraries, don't forget to change the paths to your
own system. As you can see I use /halflife/hlds_l but maybe you have used a different path, like /games/hlds_l

If you don't use the right path, the server will NOT work, so please doublecheck before you start.

We'll continue starting the server doing the following :

12. ./hlds_run -game cstrike +exec server.cfg +ip 127.0.1.1 +port 27015 +maxplayers 16 +map de_dust

(127.0.1.1 is an internal IP-address. You will have to fill in the correct (external) IP-address you are gonna use on the machine to run your server)

The server will start up and you will see the following :

Auto-restarting the server on crash
Host_Init
Added packfile /usr/local/games/hlds_l/valve/pak0.pak (985 files)
Protocol version 46
Exe version 3.1.1.0
Exe build: 14:46:34 Jun 11 2002 (2056)
WON Auth Server
Server IP address 127.0.1.1:27015
Downloading Security Module from Speakeasy.net ...
Completed downloading Security Module from Speakeasy.net
Server is in Secure Mode.

At this point you have a fully functional Counter-Strike server running for 16 players and starting up with de_dust as map. In your server.cfg
you can give the mp_timelimit how long you want each map to run on the server before it changes to another. All maps running on the server
can be viewed in the mapcycle.txt in the /hlds_l/cstrike/ directory.

Now you can do the following command to execute screen and force the process to be send to the background.

CTRL a + d (detached)

Okay, what you've done now with the CTRL a + d command, is to "detach" the current operation. You can log out of the server and keep the Counter-Strike server running.
You can go back to the process by typing screen -r followed by 'Enter' on your shell prompt.

And detach again
CTRL a + d

and back to it
screen -r
detach...

CTRL a + d
etc. etc.

Now we are gonna go one step further, and try to run multiple servers on one machine.

Telnet or SHH to your server and do the following:

1.  cd /usr/local/games/halflife/hlds_l
2.  screen
3.  export LD_LIBRARY_PATH=/halflife/hlds_l:$LD_LIBRARY_PATH
4.  ./hlds_run -game cstrike +exec server.cfg +ip 127.0.1.1 +port 27015 +maxplayers 16 +map de_dust
5.  CTRL a + d (detached)
 
6.  cd /usr/local/games/halflife/hlds_l
7.  screen 
8.  export LD_LIBRARY_PATH=/halflife/hlds_l:$LD_LIBRARY_PATH 
9.  ./hlds_run -game cstrike +exec server.cfg +ip 127.0.1.1 +port 27025 +maxplayers 16 +map de_dust 
10. CTRL a + d (detached)

11. cd /usr/local/games/halflife/hlds_l 
12. screen 
13. export LD_LIBRARY_PATH=/halflife/hlds_l:$LD_LIBRARY_PATH 
14. ./hlds_run -game cstrike +exec server.cfg +ip 127.0.1.1 +port 27035 +maxplayers 16 +map de_dust 
15. CTRL a + d (detached)

At this moment you have 3 Counter-Strike servers running on the server, each on a different port. 27015, 27025 and 27035. Now
someone should be able to connect to your servers and play on it with the following adresses:

127.0.1.1:27015
127.0.1.1:27025
127.0.1.1:27035

You can go back to your screen session at any time on your server still using the screen -r command. At that time you will get
some information on your screen, which looks like this:

login@server:/var/home/login$screen -r
There are several suitable screens on:
        102.pts-9.server        (Detached)
        103.pts-9.server        (Detached)
        104.pts-9.server        (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
login@server:/var/home/login$

Now if you do screen -r 102 you would return to the 27015 session. If you do screen -r 103 you'll return to the 27025 session,
and screen -r 104 for the 27035 session.

If we go one step further with multiple servers on one machine, it is also possible to let each server start up with a different
server.cfg, motd.txt and mapcycle.txt

You just add the following cvar's to your startup line.

+servercfgfile
+mapcyclefile
+motdfile

When you want to use 3 different mapcycle.txt's, server.cfg's and motd.txt's you're startup line would look like this:

./hlds_run -game cstrike +ip 127.0.1.1 +port 27015 +servercfgfile server.27015 +mapcyclefile mapcycle.27015 +motdfile motd.27015 +maxplayers 16 +map de_dust
./hlds_run -game cstrike +ip 127.0.1.1 +port 27025 +servercfgfile server.27025 +mapcyclefile mapcycle.27025 +motdfile motd.27025 +maxplayers 16 +map de_dust
./hlds_run -game cstrike +ip 127.0.1.1 +port 27035 +servercfgfile server.27035 +mapcyclefile mapcycle.27035 +motdfile motd.27035 +maxplayers 16 +map de_dust

And offcourse you can run these lines under screen as well.

The above settings about running multiple servers are tested by me on Counter-Strike servers. I haven't tested it on Day of Defeat or Frontline Force servers.
I don't know that it will work on those mod's, but I guess so. They will certainly NOT work on former Beta version of Counter-Strike like Beta 5.2 and Beta 6.1.

The above written startup lines and cvar's work good for Counter-Strike 1.5. If you have any problems or questions you can contact me using the forum.