Source games on a Linux install

Post Reply
joshh20
This is my homepage
This is my homepage
Posts: 146
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sat Mar 02, 2013 1:35 pm

Source games on a Linux install

Post by joshh20 »

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

Code: Select all

apt-get update
After this, update the other packages on the system with this

Code: Select all

apt-get upgrade
Now, to install screen

Code: Select all

apt-get install screen
Grab the 32 bit binaries just in-case

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
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

Code: Select all

adduser steam
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

Code: Select all

nano /etc/security/limits.conf
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

Code: Select all

steam            -       rtprio          20
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

Code: Select all

mkdir steam-server
Change your working directory to the new folder

Code: Select all

cd steam-server
Download Steam

Code: Select all

wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
Extract the file

Code: Select all

tar xzvf steamcmd_linux.tar.gz
To install the wanted game server, we will run the script that we have just downloaded. So type

Code: Select all

./steamcmd.sh
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

Code: Select all

force_install_dir /ssd/servers/tf2
Otherwise, if you do not want to use an SSD, or do not have one, you can just install it to your home directory

Code: Select all

force_install_dir /home/steam/servers/tf2
To download any files, it is necessary to log in

Code: Select all

login anonymous
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

Code: Select all

app_update 232250 validate
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.

Code: Select all

nano tf2-startup.sh
Then paste this into the terminal with Control-V on Windows, or Command-V if you are on a Mac

Code: Select all

chrt -r 20 /home/steam/servers/tf2/./srcds_run -game tf -ip xxx.xxx.xxx.xxx +maxplayers 24 -console -nocrashdialog
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.

Code: Select all

chmod +x tf2-startup.sh
5 Running the server
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
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.

Code: Select all

./tf2-startup.sh
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.
Attachments
server.txt
(1.03 KiB) Downloaded 359 times
Post Reply