Source games on a Linux install
Posted: Tue Jul 22, 2014 7:11 pm
Multiple different games can be installed using this method, which includes most Valve games that could be ordered regularly through NFO's website.
1 Select your distribution (OS)
While there are various distributions of Linux available through the control panel, it may be difficult to know which one to pick. Gentoo is one of the most customizable distributions out there, but for a first time user, or even someone with moderate experience, it can be daunting, so it's not recommended here. CentOS is widely used, but is not very good for game servers because of the default kernel settings, which provide poor performance. For these reasons, we will be going with the latest release of Debian, although if you have a preference for Ubuntu, that would also be comparable. Keep in mind, the steps that are being shown here should be very close for all distributions, with only minor differences.
2 Configure the OS
We will be using a utility called screen that enables you to run interactive applications inside a separate console window that doesn't close when you disconnect from your terminal.
First, to update the packages list type
After this, update the other packages on the system with this
Now, to install screen
Grab the 32 bit binaries just in-case
Since we are logged in as root, we will now create a new user. It is a very bad idea to run anything as root that you don't absolutely have to, as it a less restricted account and therefore, there are many more opportunities for something to go wrong. The new account can be named whatever you like but we will be naming it steam here.
Create the new user account
You will then be prompted to set a password, and then to confirm it. Once you are done setting the password, you can keep pressing enter until the prompt has finished.
Game servers need to have good timers to run off of, so it is important to run them as a higher priority than other system processes. Chrt is a preinstalled package that provides a way to do this.
Edit the limits.conf file
The file will open on your terminal. You should navigate to the bottom with the down arrow key. Arrow up one line above the "# End of file" and then enter this
Then, to save the file, press Control-X on your keyboard, then press y, and then enter.
Now we will log into the new account we created earlier. Log out of the root account by typing exit. To sign in on the user, you will change the account name from root to steam.
3 Installing Steam and the Source engine game
Create a folder for Steam
Change your working directory to the new folder
Download Steam
Extract the file
To install the wanted game server, we will run the script that we have just downloaded. So type
It is important to know where you want the game base files to be installed on your system. If you have an SSD and want the game to be running off of there
Otherwise, if you do not want to use an SSD, or do not have one, you can just install it to your home directory
To download any files, it is necessary to log in
Valve's system works with IDs assigned to different game server installations, to find the one for your game, check here: https://developer.valvesoftware.com/wik ... ed_Servers
In this case, we are setting up a TF2 server, so the ID is 232250, so we run this command
This operation may take several minutes, depending on how busy Valve's servers are.
Now to close the Steam installer, type quit.
4 Creating the startup script
To run the server, a script is needed.
Then paste this into the terminal with Control-V on Windows, or Command-V if you are on a Mac
Replace the xxx.xxx.xxx.xxx with the IP address that is assigned to your server and that you are wanting to use.
Then save and close the script.
In order to let the system know that the script is allowed to be run, the file permission must be adjusted.
5 Running the server
Finally we are ready to run the server. We will open it inside a screen so that it always runs.
Ensure that there is a configured server.cfg file in servers/tf2/tf/cfg. An example server cfg file is attached to this post, just rename it to server.cfg file before running it.
Time to run the server.
To make sure it is running with the settings you intended, type status in the window, and you will see some generalized information.
To detach from the screen and allow it to run in the background, press Control-a-d. If you want to reattach to the screen to check the console, type screen -r TF2. If you need to pause or scroll up a screen window, you can press Control-a and then press Escape once. Then you may arrow up to view logs higher up that may have disappeared off the window. To get out of this mode, press Escape again.
1 Select your distribution (OS)
While there are various distributions of Linux available through the control panel, it may be difficult to know which one to pick. Gentoo is one of the most customizable distributions out there, but for a first time user, or even someone with moderate experience, it can be daunting, so it's not recommended here. CentOS is widely used, but is not very good for game servers because of the default kernel settings, which provide poor performance. For these reasons, we will be going with the latest release of Debian, although if you have a preference for Ubuntu, that would also be comparable. Keep in mind, the steps that are being shown here should be very close for all distributions, with only minor differences.
2 Configure the OS
We will be using a utility called screen that enables you to run interactive applications inside a separate console window that doesn't close when you disconnect from your terminal.
First, to update the packages list type
Code: Select all
apt-get update
Code: Select all
apt-get upgrade
Code: Select all
apt-get install screen
Code: Select all
dpkg --add-architecture i386
apt-get update
apt-get install lib32z1 libncurses5:i386 libbz2-1.0:i386 lib32gcc1 lib32stdc++6 libtinfo5:i386 libcurl3-gnutls:i386
Create the new user account
Code: Select all
adduser steam
Game servers need to have good timers to run off of, so it is important to run them as a higher priority than other system processes. Chrt is a preinstalled package that provides a way to do this.
Edit the limits.conf file
Code: Select all
nano /etc/security/limits.conf
Code: Select all
steam - rtprio 20
Now we will log into the new account we created earlier. Log out of the root account by typing exit. To sign in on the user, you will change the account name from root to steam.
3 Installing Steam and the Source engine game
Create a folder for Steam
Code: Select all
mkdir steam-server
Code: Select all
cd steam-server
Code: Select all
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
Code: Select all
tar xzvf steamcmd_linux.tar.gz
Code: Select all
./steamcmd.sh
Code: Select all
force_install_dir /ssd/servers/tf2
Code: Select all
force_install_dir /home/steam/servers/tf2
Code: Select all
login anonymous
In this case, we are setting up a TF2 server, so the ID is 232250, so we run this command
Code: Select all
app_update 232250 validate
Now to close the Steam installer, type quit.
4 Creating the startup script
To run the server, a script is needed.
Code: Select all
nano tf2-startup.sh
Code: Select all
chrt -r 20 /home/steam/servers/tf2/./srcds_run -game tf -ip xxx.xxx.xxx.xxx +maxplayers 24 -console -nocrashdialog
Then save and close the script.
In order to let the system know that the script is allowed to be run, the file permission must be adjusted.
Code: Select all
chmod +x tf2-startup.sh
Finally we are ready to run the server. We will open it inside a screen so that it always runs.
Code: Select all
screen -S TF2
Time to run the server.
Code: Select all
./tf2-startup.sh
To detach from the screen and allow it to run in the background, press Control-a-d. If you want to reattach to the screen to check the console, type screen -r TF2. If you need to pause or scroll up a screen window, you can press Control-a and then press Escape once. Then you may arrow up to view logs higher up that may have disappeared off the window. To get out of this mode, press Escape again.