Running a Terraria Server on Linux

In this tutorial, we will show you how to set up a Terraria server on Linux systems such as Ubuntu.

Terraria Dedicated Server Linux

Terraria is a super popular 2D action-adventure sandbox game. This game allows you to dig, fight, and explore through a massive procedurally generated world. Part of the fun of Terraria is that it has excellent built-in multiplayer.

The reason you might want to use a dedicated server is that it can run 24/7 without you needing to keep the game open on your machine. This allows other people to continually play without you being there.

Linux-based systems like Ubuntu are great for running a Terraria server. The operating system is fairly lightweight, allowing you to get more out of your machine. So, if you want to pay for a server from a provider like DigitalOcean, you can get away with less.

To run the Terraria server on Linux, we will use third-party software called TShock. TShock is an alternative server that retains all of the vanilla server’s core functionality but adds even more features.

By the end of this tutorial, you will have a Terraria server up and running on your machine.

Installing and Running a Terraria Server on Linux

In the following sections, we will walk you through downloading and running a Terraria server on your Linux system.

These steps are all going to be within the terminal, but they are super straightforward for most people to follow. You can access the terminal on most desktop-based systems by pressing CTRL + ALT + T.

Before proceeding, you must open port 7777 of your firewall, and if you are hosting this from your home network, you must port forward that port.

Preparing your System for the Terraria Server

1. Before we start, we will ensure we have an updated package list cache.

On Debian-like operating systems such as Ubuntu, you can update this cache using the following command. The following steps should work fine if your system uses the apt package manager.

sudo apt update

2. Once we have updated the cache, we must install the tools we need to download and run the Terraria server on Linux. Most of these packages typically come preinstalled, but ensuring they are installed doesn’t take much effort.

You can install all required packages using the command below in the terminal.

sudo apt install unzip wget tar screen

3. With the packages we need installed, our next step is creating a user to run the server. This is good practice as it isolates the game server from the rest of your system.

You can create a user called “terraria” by using the useradd command. The “-m” option will generate the home directory for this user.

sudo useradd terraria -m

4. To download and run the Terraria server we will want to swap to the new user we created.

You can change to this new user by running the command below.

sudo -u terraria -s

Creating a Folder to Store the Terraria Server on Linux

5. Now that you are using the terminal as the new “terraria” user let us create a directory where we can store the server.

You can create this directory by using the mkdir command within the terminal.

mkdir -p ~/server

6. With the directory created, change into it by running the following command.

We will download and save the TShock software to our Linux system in this directory.

cd ~/server

Installing the Terraria Server on Linux using TShock

7. To make things easier, we will set a bash variable to keep track of the architecture you are using. This will save having multiple sets of commands that basically do the same thing.

If you are running a 64-bit x64 system, use the following command.


Alternatively, if you are using an ARM system like the Raspberry Pi 5, you should use the command below instead.


8. The next step is to download the current release of TShock onto your Linux device. Thanks to us installing wget earlier, downloading this software straight from their GitHub is a pretty straightforward process.

Use the command below to download the TShock Terraria server to your Linux system.

wget$ -O

9. The server comes packaged within both a zip and tar archive.

The outer layer is a zip package that we must extract using the unzip command.


10. For some reason, the TShock server is kept within yet another archive.

Luckily, you can extract tar archives super fast using the following command.

tar -xvf TShock-Beta-linux-$OSTYPE-Release.tar

11. With the Terraria server extracted, we can clean up the two archives by deleting them using the rm command.

You don’t need these archives anymore so there is no point in keeping them on your system.

rm TShock-Beta-linux-$OSTYPE-Release.tar

Running the TShock Installer

12. We are finally at the point we can now star start setting up the Terraria server on our Linux system using TShock.

To start this process, we will want to launch the TShock installer. This installer will download the Dotnet libraries required to run this server.


13. Once the installation process completes, you can quit out of the installer by pressing CTRL + C twice.

We will be doing things like setting the maximum number of players and more with the start-up command.

TShock (Intensity) now running.
AutoSave Enabled
Backups Enabled
Welcome to TShock for Terraria!
TShock comes with no warranty & is free software.
You can modify & distribute it under the terms of the GNU GPLv3.

14. We have now finished using our “terraria” user so we can use “exit” to return to our normal user.


Writing a Service for your Linux Terraria Server

15. We will want to write a service file to get the Terraria Server to start when our system powers on. Most Linux operating systems, like Ubuntu, use systemd to handle services.

You can begin writing a service for Terraria by running the command below.

sudo nano /etc/systemd/system/terrariaserver.service

16. Within this file, you will want to add the following lines.

While typing out these lines, there are particular placeholders you must place. These configure the maximum number of players and your world name.

  • <NUMPLAYERS>: Replace this with the maximum number of players. This can be value between 1 and 255.
  • <WORLDNAME>: Use this placeholder to specify the name of your world. Since we are using the “autocreate” option TShock will generate this world if its missing.
  • <WORLDSIZE>: The final value you must specify sets the size of the world that is generated.
    • 0 – Small
    • 1 – Medium
    • 2 – Large

If you want to configure the server further, check out the official documentation.

Description=Terraria Server

ExecStart=/home/terraria/server/TShock.Server -port 7777 -maxplayers <NUMPLAYERS> -world /home/terraria/worlds/<WORLDNAME> -autocreate <WORLDSIZE>


17. Once you have finished with the service file, you can save and quit by pressing CTRL + X, Y, and then ENTER.

18. To ensure that our Terraria server boots when our Linux system does, we must enable it.

To enable the service, you will need to run the command below.

sudo systemctl enable terrariaserver

19. Enabling a service enables it to start at boot, but it does not start the service immediately.

To start your Terraria server, you should use the command below.

sudo systemctl start terrariaserver

At this point, you should now be able to connect to your Terraria server using the IP Address of your machine and port 7777.


By this point in the tutorial, you should now have the Terraria server running on your Linux machine.

Self-hosting a Terraria server is a straightforward process that anyone can do. Using a Linux system allows you to make the most of your hardware. If you are using a server provider, this is even better, as you can afford to go with a less powerful machine, which can be significantly cheaper.

Please comment below if you have any issues when trying to get a Terraria server running.

If you found this guide helpful, please check out our many other game server tutorials to see the other game servers you can self-host.

Leave a Reply

Your email address will not be published. Required fields are marked *