Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 02:21, 7 December 2025 by Webb (talk | contribs)
This is a WIP updated version of the Linux dedicated server article. I want to ask for feedback before moving out of my user namespace. The original article was adapted and revised from a guide written by Raizo, the original of which can be found here: https://blog.raizo.dev/posts/tf2-classic-linux-server-tutorial/

Prerequisites

  • A Linux server running Ubuntu Server* on an x86_64 CPU** with root/administrator access
  • A SFTP/SSH client (PuTTY, Termius, FileZilla, MobaXterm)
  • At least 20GB of free storage
  • A minimum of a 10Mbps upload speed if you intend on hosting a server over the Internet. More bandwidth may be needed if custom maps are used.

* This guide was written for and tested on Ubuntu Server 24.04 LTS Minimal. Other distros may use different package names and conventions.

** Using an x86 compatibility layer like Box86 for another architecture is unsupported and may not work.

Reading this article

A command prefixed by # is meant to be run as root.

A command prefixed by $ is meant to be run as a regular user without root permissions. In this case the srcds user.

SteamCMD shell commands will use the Steam> prefix.

Some commands are listed in-line with the rest of a paragraph and lack this symbol, in which case you should run the command as whichever account you're currently logged in with.

Creating a user for SteamCMD and Source SDK Base 2013 Dedicated Server

Pick a directory to install your server into. Many put it under a directory in /opt, but for this guide we'll be using /home/srcds.

Create a disabled user with a home directory:

# useradd -s /bin/false -mr srcds

-m creates a home directory for the new user, -r specifies that it's a system account that will not have a password, and -s /bin/false prevents the account from having a default shell.

Installing Source SDK Base 2013 Dedicated Server (srcds), SteamCMD, and dependencies

The SteamCMD package is in the multiverse repos. TF2Classic and SteamCMD require i386 (32-bit) libraries to function. You also need 7-Zip to extract TF2Classic.

# add-apt-repository multiverse
# dpkg --add-architecture i386
# apt update

Install SteamCMD, and miscellaneous packages that we'll be using.

webbnote: libcurl4-gnutls-dev broken

# apt install dialog
# apt install steamcmd p7zip aria2 tilde lib32z1 libbz2-1.0:i386 lib32gcc-s1 lib32stdc++6 libcurl3-gnutls:i386 libsdl2-2.0-0:i386 libcurl4-gnutls-dev libcurl4-gnutls-dev:i386 wget

*Note:See Developer Wiki SteamCMD Repository Packages if your distro is having issues getting steamcmd.

Log out of your current session, and relogin. Switch to the srcds user you created:

# sudo -Hu srcds bash
$ cd ~
$ . /etc/environment
$ steamcmd

You should be dropped into a SteamCMD shell. We can install the SDK now. Note that force_install_dir must be ran before login anonymous.

Steam>force_install_dir /home/srcds/sdk
Steam>login anonymous
Steam>app_update 244310 -beta previous2021
Steam>quit

If everything went well, srcds itself should be installed and you should be back at your user shell.

Downloading TF2 Classic

We'll be downloading the archived verison of TF2C. You can also use the TF2CDownloader if you wish.

$ wget https://wiki.tf2classic.com/archive/tf2classic-2.2.3.zip -O /tmp/tf2classic.zip
$ mkdir ~/sdk/tf2classic
$ cd ~/sdk/tf2classic
$ 7z x /tmp/tf2classic.zip && rm /tmp/tf2classic.zip

This will downloaded the latest archive of TF2C, create its directory, and extract it. If everything succeeds it will delete tf2classic.zip.

Valve changed some shared object file names in the SDK and the objects we’re given have not adapted to the new names. Since these are simply renames, we can symlink them. Your server will not start without doing this.

Enter the bin directory by typing, exactly:

$ cd bin

Run the following commands to create the symlinks in the bin folder:

$ cd ~/sdk/bin
$ ln -s datacache_srv.so datacache.so
$ ln -s dedicated_srv.so dedicated.so
$ ln -s engine_srv.so engine.so
$ ln -s materialsystem_srv.so materialsystem.so
$ ln -s replay_srv.so replay.so
$ ln -s scenefilecache_srv.so scenefilecache.so
$ ln -s shaderapiempty_srv.so shaderapiempty.so
$ ln -s studiorender_srv.so studiorender.so
$ ln -s vphysics_srv.so vphysics.so
$ ln -s soundemittersystem_srv.so soundemittersystem.so
$ cd ~/sdk/tf2classic/bin
$ ln -s server.so server_srv.so

We can also fix steamclient.so errors by symlinking a file to .steam.

$ mkdir -p ~/.steam/sdk32
$ ln -s ~/sdk/bin/steamclient.so ~/.steam/sdk32/

Testing the server

Before proceeding, we can test the server to make sure the install works.

$ cd ~/sdk
$ ./srcds_run -game tf2classic +map ctf_2fort +sv_password changethis

If all goes well, it should launch and be joinable.

Server Configuration

Generate your server config(s) on cfg.tf.

Make sure the server type is set to “Internet and LAN” if you want players outside your LAN to be able to join (you may need to port forward if you’re on consumer broadband or open ports on your firewall).

Upload the generated ZIP file to your server using SFTP, unzip the folder using:

unzip <archive>.zip

And merge the cfg folder with /home/srcds/sdk/tf2classic/cfg/.

Running the server

Creating the server script

Change into the server directory with:

$ cd /opt/tf2classic/server/

Create a script to run the server with one simple command. Use any text editor of your choice to create runserver.sh where srcds_run is located. For the sake of those unfamiliar with terminal text editing, we'll be using nano. Run:

$ nano runserver.sh

Fill it with this line (you may be able to paste using Shift+Insert):

./srcds_run -console -game tf2classic +map pl_upward +maxplayers 24

Feel free to change the map and maxplayers. There are more arguments, but we’ll keep it basic.

Save the file by clicking CRTL+X, and then Y to write your changes.

Now, make the script executable with:

$ chmod +x runserver.sh

Finally, all you need to do to start the server is run ./runserver.sh!

If you want it to run even after closing the terminal window, run nohup ./runserver.sh & followed by disown

Systemd & Crontab for automated start, restart and updating

For easier automation of server restarts, updating, and booting alongside the system, you may use systemd, which is the default init system for most modern Linux distros and cronjobs.

Create file ssdk2013mp-update and fill in the following

@ShutdownOnFailedCommand 1 //set to 0 if updating multiple servers at once
@NoPromptForPassword 1
login anonymous
app_update 244310 -beta previous2021
quit

Make it executable with chmod +x ssdk2013mp-update

This script will update the underlying Source SDK 2013 MP Dedicated Server, you may execute it by itself, but in this case we will use it for automatic updates.

Next, create a service file in /etc/systemd/system/

Example tf2classic.service:

[Unit]
Description=TF2Classic
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
User=steam
WorkingDirectory=/home/tf2classic
RemainAfterExit=yes
ExecStartPre=/usr/games/steamcmd +runscript /opt/tf2classic/ssdkb2013mp-update
ExecStartPre=/opt/tf2classic/TF2CDownloaderLinux --update
ExecStart=/opt/tf2classic/server/srcds_run -console -game tf2classic +map tr_walkway_fastcat_v1 -port 27020 +maxplayers 32 +sv_setsteamaccount XXXXXXX
TimeoutStartSec=infinity
Restart=always

[Install]
WantedBy=multi-user.target

Then, enable the service to start with the init system:

# systemctl enable tf2classic.service

Next, switch to the root user using sudo su and execute crontab -e. This is where you can set cronjobs, include something like the following:

# Restart and update check for TF2Classic every day at 4 AM.

0 4 * * * systemctl restart tf2classic.service

You may create as many services as you have TF2C servers but remember to name the service files uniquely, enable them in systemctl, and add them to the crontab.

Systemd manual start, stop, restart/update

If you don't wish to use the service files above to automatically boot servers, or you need to perform these actions for maintenance: you may issue commands to manually start, stop, restart, or update the server(s) through systemd.

# systemctl restart tf2classic # in case you need to restart manually or to grab updates!! 
# systemctl stop tf2classic # in case you need to stop the server manually
# systemctl start tf2classic # in case you need to start the server manually
# systemctl disable tf2classic # in case you need to stop the server from booting as your system initializes 
# systemctl enable tf2classic # in case you need to start the server to boot as your system initializes 


See also Dedicated Linux Server Extras.