Team Fortress 2 on Debian and Ubuntu
Updated by Linode Written by Elle Krout
Dedicated CPU instances are available!Linode's Dedicated CPU instances are ideal for CPU-intensive workloads like those discussed in this guide. To learn more about Dedicated CPU, read our blog post. To upgrade an existing Linode to a Dedicated CPU instance, review the Resizing a Linode guide.
Team Fortress 2 is a team-based, first-person shooter, where you and a team of fellow players can play a variety of game modes. From capture the flag, to a battle pitting your team against a robotic horde, there are numerous options to choose. Setting up a personal game server puts you in control of what game modes and maps you use, as well as a variety of other settings to customize your experience.
Before You Begin
You will need a Steam account and a copy of Team Fortress 2.
Complete our guide: Install SteamCMD for a Steam Game Server. This will get SteamCMD installed and running on your Linode and this guide will pick up where the SteamCMD page leaves off.
NoteThis guide is written for a non-root user. Commands that require elevated privileges are prefixed withsudo
. If you’re not familiar with thesudo
command, you can check our Users and Groups guide.
Prerequisites for Team Fortress 2
From the SteamCMD guide, two additional steps are needed specifically for TF2.
Add an iptables firewall rule. This command assumes that you have only the iptables rules in place from the SteamCMD guide. This inserts a rule after the pre-existing iptables rules for SteamCMD.
sudo iptables -I INPUT 7 -p udp -m udp --dport 26900:27030 -j ACCEPT
After entering the above rule, run iptables-persistent again. You’ll be asked if you want to save the current IPv4 and IPv6 rules. Answer
yes
for IPv4 andno
for IPv6.sudo dpkg-reconfigure iptables-persistent
Install an additional 32-bit package:
sudo apt-get install lib32tinfo5
Install Team Fortress 2
Be sure you are in the directory
~/Steam
, then access theSteam>
prompt.cd ~/Steam && ./steamcmd.sh
From the SteamCMD prompt, login anonymously:
login anonymous
Or log in with your Steam username:
login example_user
Install TF2 to the
Steam
user’s home directory:force_install_dir ./tf2 app_update 232250
This can take some time. If the download looks as if it has frozen, be patient. Once the download is complete, you should see this output:
Success! App '232250' fully installed. Steam>
Quit SteamCMD:
quit
Note
To update TF2, run the above 4 commands again.
Configure Team Fortress 2
Maps
You can select from a variety of maps on which you can play Team Fortress 2, a number of which are already installed to the server.
In order to create a custom list of maps for your server, create mapcycle.txt
within the tf2/tf/cfg
directory. The best way to do this is to copy the example file and edit it to include your chosen maps.
Navigate to
Steam/tf2/tf/cfg
:cd ~/Steam/tf2/tf/cfg
Copy
mapcycle_default.txt
:cp mapcycle_default.txt mapcycle.txt
Open the file and add or remove maps as desired.
Message of the Day
The “Message of the Day” appears when joining a server. This can be a message to your normal group of players, a statement about the server’s settings, or anything else. Configure this by editing the files:
~/Steam/tf2/tf/cfg/motd_default.txt
~/Steam/tf2/tf/cfg/motd_text_default.txt
The motd_default.txt
file can contain HTML and is displayed as a website upon loading the server in-game. The modt_text_default.txt
file should be the text copy, with no additional code.
Server.cfg
The file ~/Steam/tf2/tf/cfg/server.cfg
is what contains all of the settings you need to customize the loadout of your game. A server.cfg
file is not needed to run the game but we have a sample config file here which you can edit for your own use.
NoteFor the configuration of this file,0
means off and1
means on.
Startup Script
Create a startup script for TF2 with the following contents:
- ~/starttf2.sh
-
1 2 3 4
#!/bin/sh cd ./Steam/tf2 screen -S "Team Fortress 2 Server" ./srcds_run -game tf +map ctf_2fort.bsp
When run, the script will change directories to
~/Steam/tf2
and execute TF2 in a Screen session.Optionally, replace
cft_2fort.bsp
with the name of your chosen map’s file, or replace+map ctf_2fort.bsp
with+randommap
for a randomized map selection.Make the script executable:
chmod +x ~/starttf2.sh
Using the Server
Now that your server is installed and configured, it can be launched by running the
starttf2.sh
script from yoursteam
user’s home directory.cd ~/ && ./starttf2.sh
Caution
From this point, do not press the Control+C keys while in the console unless you want to stop TF2.To detach from the screen session running the server console, press these two key combinations in succession:
Control+A
Control+DTo bring the console back, type the following command:
screen -r
To stop the server, bring back the TF2 console and press CONTROL + C.
RCON
RCON allows you to make changes to your server from inside of the game.
To start using RCON, go to the Options setting in the game, and then select Advanced…
From here, check Enable developer console and apply these settings.
To make changes in-game, it is recommended that you switch to spectator mode, and then press the backtick button (
`
) to access the developer’s console.Log in to RCON by typing in
rcon_password
followed by your password.
RCON Commands
The commands for RCON are as follows:
rcon sv_password
: Add a server passwordrcon users
: Display a list of users on the serverrcon kick
: Boot user from serverrcon banid
: Ban a user by their IDrcon banip
: Ban a user by their IPrcon removeid
: Remove a user from the ID ban listrcon removeip
: Remove a user from the IP ban listrcon maps
: Displays the maps available to your serverrcon changelevel [mapname]
: Change to set map
Most server.cfg
options can also be altered through RCON using the same values. For example, should you want to enable friendly fire, enter rcon mp_friendlyfire 1
.
Join our Community
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.