Excited to forge your own realm in the world of Terraria? This guide will lead you through the steps of setting up your dedicated server on Ubuntu. By the end, you’ll have your very own Terraria server, ready to host adventures with friends in your own gaming sanctuary.
Update Repository and Install Dependencies
Before we delve into the installation process, it’s essential to ensure our system is up to speed and equipped with all the necessary libraries. Let’s kick things off by running the following commands in your terminal:
sudo apt update -y
sudo apt install -y curl nano unzip
Add a New Linux User
Following that, we’ll establish a dedicated user specifically for managing the Terraria Server. Execute the following command to create a new user named ’terraria':
sudo adduser terraria
Download Terraria Dedicated Server
Transitioning to the directory of the freshly established user, proceed to acquire the Terraria Dedicated Server by employing the subsequent command:
cd /home/terraria
v=$(curl -s "https://terraria.wiki.gg/wiki/Server" | grep -oP 'server-\K\d+(?=\.zip)' | head -n 1)
curl -o terraria.zip https://terraria.org/api/download/pc-dedicated-server/terraria-server-${v}.zip
unzip terraria.zip "${v}/Linux/*"
mv ${v}/Linux/* .
rm -rf ${v} terraria.zip
Grant Permissions and Change Ownership
Ensure the server files have the necessary permissions and are owned by the ’terraria’ user with the following commands:
sudo chmod +x TerrariaServer.bin.x86_64
sudo chown -R terraria:terraria /home/terraria
Create Server Config File
Time to create a config file:
nano /home/terraria/config.ini
The list of config commands is available here.
autocreate=1
difficulty=1
language=en-US
maxplayers=4
password=secret
port=7777
secure=1
world=world1.wld
worldname=world1
worldpath=/home/terraria
Create a Service Unit File
Now, let’s create a service unit file for Terraria Dedicated Server using nano text editor. For example:
sudo nano /etc/systemd/system/terraria.service
Paste the following contents into the file:
[Unit]
Description=Terraria Dedicated Server
After=network.target
[Service]
Type=simple
User=terraria
WorkingDirectory=/home/terraria
ExecStart=/home/terraria/TerrariaServer.bin.x86_64 -config config.ini
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Reload systemd and Enable Service
Reload systemd to apply the changes and enable the terraria service to start on boot:
sudo systemctl daemon-reload
sudo systemctl enable terraria
Start the Service
Finally, start the terraria service using the following command:
sudo systemctl start terraria
Your installation and configuration of the Terraria Server on Ubuntu are complete!