Linux dedicated server
![]() | This guide assumes that the reader has a basic understanding of using the Linux command line terminal. |
This article is a step-by-step guide to installing and running a Team Fortress 2 dedicated server on GNU/Linux (x86 or x86_64). It covers installing SteamCMD, downloading the TF2 server files, configuring the server, and running it. The instructions are written to be distribution-agnostic. In most cases the process is the same across Linux distributions; only package names differ. Users must ensure required 32-bit libraries are installed. See the example below for Debian/Ubuntu.
This article uses standard Linux command notation:
#
– run as the root user (or withsudo
).$
– run as a regular user../
– execute a file in the current directory.
Contents
Docker container
If your server host supports Docker, you can launch TF2 quickly using a prebuilt container:
$ docker run -d --net=host --name=tf2-dedicated \ -e SRCDS_TOKEN={YOURTOKEN} \ cm2network/tf2
Replace {YOURTOKEN
} with your Steam Game Server Token (see the Steam dev page).
The container updates itself on restart.
To run multiple servers, specify extra environment variables such as ports:
$ docker run -d --net=host \ -e SRCDS_PORT=27016 \ -e SRCDS_TV_PORT=27021 \ -e SRCDS_TOKEN={YOURTOKEN} \ --name=tf2-dedicated2 \ cm2network/tf2
See the Docker Hub page for full details.
Manual installation
Requirements
- glibc 2.3.6 or newer.
- ~8 GB free disk space.
- 32-bit compatibility libraries if using a 64-bit system.
Example for Debian/Ubuntu/Mint (64-bit):
# dpkg --add-architecture i386 # apt update # apt install lib32z1 libncurses5:i386 libbz2-1.0:i386 \ lib32gcc-s1 lib32stdc++6 libtinfo5:i386 \ libcurl3-gnutls:i386 libsdl2-2.0-0:i386
On other distributions, install the equivalent 32-bit libraries with your package manager.
Download and install the SteamCMD Tool
It is recommended to create a dedicated user (e.g. gameserver
):
# useradd --create-home gameserver
Switch to that user and create a working directory:
$ mkdir ~/hlserver $ cd ~/hlserver
Download and extract SteamCMD:
$ wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz $ tar zxf steamcmd_linux.tar.gz
Verify installation:
$ ./steamcmd.sh +help +quit
Download the TF2 server
Run SteamCMD and install TF2 into ~/hlserver/tf2
:
$ ./steamcmd.sh +force_install_dir ~/hlserver/tf2 \ +login anonymous +app_update 232250 +quit
For the prerelease branch, add -beta prerelease
before +app_update
.
Re-run this command to update in the future.
Server configuration
Change to the config folder:
$ cd ~/hlserver/tf2/tf/cfg
Create server.cfg
($ nano server.cfg
) and add:
// Example TF2 server.cfg hostname "My TF2 Server" sv_contact "admin@example.com" rcon_password "MyStrongRconPass" mp_timelimit 30 mp_maxrounds 10
Also edit/create:
motd.txt
– Message of the Day.mapcycle.txt
– map rotation list.pure_server_whitelist.txt
– optional whitelist.
Launch script
Create ~/hlserver/tf2/tf2.sh
with:
#!/bin/sh cd ~/hlserver/tf2 || exit 1 exec ./srcds_run -console -game tf +map ctf_2fort \ +sv_pure 1 +maxplayers 24 +sv_setsteamaccount [STEAMTOKEN]
Make it executable and run:
$ chmod +x tf2.sh $ ./tf2.sh
You must use a valid Steam Game Server Token to appear in the server browser.
Ports
Default ports:
- UDP 27015 – game traffic
- TCP 27015 – RCON
- UDP 27020 – SourceTV
Open with UFW:
# ufw allow 27015/udp # ufw allow 27020/udp
iptables example:
# for port in 27015 27020; do for proto in udp tcp; do iptables -A INPUT -p $proto --dport $port \ -m state --state NEW,ESTABLISHED -j ACCEPT done done
Utilities
Keep the server running after logout with screen:
$ screen -m -S tf2 ./tf2.sh
Detach with Ctrl+A, D. Reattach with screen -r tf2
.
Persistence (systemd)
Create /etc/systemd/system/tf2server.service
:
[Unit] Description=Team Fortress 2 server [Service] Type=simple User=gameserver ExecStart=/home/gameserver/hlserver/tf2/tf2.sh [Install] WantedBy=multi-user.target
Enable at boot:
# systemctl daemon-reload # systemctl enable tf2server
Plugins
Use SourceMod and MetaMod for admin features and plugins:
Troubleshooting
- SteamAPI_Init failed – safe to ignore.
- Missing steamclient.so – copy to
~/.steam/sdk32/
. - Segmentation fault – usually missing 32-bit libraries.
- LAN-only mode – add a
steam_appid.txt
with232250
. - RCON issues – add
+ip 0.0.0.0
andrcon_address 0.0.0.0
. - Run with
-debug
to generatedebug.log
. - Auto-update requires
-steam_dir
and-steamcmd_script
. - Arch DNS error →
# ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
.