Deploy a game server on dedicated hardware
Dedicated game server hosting gives you what a shared control panel cannot: a whole machine, root access, and tick times that do not wobble when a neighbour gets busy. This guide is a top-to-bottom runthrough of how to host your own game server on a bare Ubuntu 24.04 LTS box, with two worked examples you can paste and run.
We build a Minecraft dedicated server setup with Paper, then a steamcmd dedicated server running Valheim, and finish with the parts people skip: firewall rules, tested backups, and monitoring that tells you before players do. The server is unmanaged, so you are the sysadmin here. Everything below is standard Linux practice.
Base setup and a dedicated games user
Before installing any game, get the box itself into a safe state: change the delivered root password, apply updates, add your SSH key, disable password login, and enable automatic security patches. That whole first-hour checklist lives in our guide on getting your server online, so we will not repeat it. Assume it is done.
Never run a game server as root. A game server is a network-facing process that parses untrusted input from the internet, so it should own as little as possible. Create one unprivileged user that holds every game under its home directory. It gets no sudo, no login shell for humans, just a home to keep files in.
Create the games user and its directory. It has no password and cannot use sudo.
sudo adduser --system --group --home /home/games --shell /bin/bash games
sudo mkdir -p /home/games
sudo chown games:games /home/games
To run commands as that user during setup, open a shell as games. Return to your admin user with exit.
sudo -u games -i
Worked example A: Minecraft Java with Paper
Paper is the standard high-performance Minecraft server: a drop-in Spigot fork that holds tick rate far better than vanilla and takes the same plugins. Modern Minecraft needs Java 21, which we install from the official Adoptium Temurin apt repository so it stays patched through apt.
Add the Temurin repository and install the Java 21 runtime. Run this as your admin user (it needs sudo). VERSION_CODENAME resolves to noble on Ubuntu 24.04.
sudo apt-get update
sudo apt-get install -y wget gpg apt-transport-https jq
sudo mkdir -p /etc/apt/keyrings
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public \
| sudo gpg --dearmor -o /etc/apt/keyrings/adoptium.gpg
echo "deb [signed-by=/etc/apt/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb $(. /etc/os-release; echo $VERSION_CODENAME) main" \
| sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt-get update
sudo apt-get install -y temurin-21-jre
Now switch to the games user and download the latest Paper build for the version you want. Set MC_VERSION to your target Minecraft version; the API returns the newest build for it. If Paper changes its download API, grab the direct URL from papermc.io/downloads instead.
sudo -u games -i
mkdir -p ~/minecraft && cd ~/minecraft
MC_VERSION=1.21.4
BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds" | jq -r '.builds[-1].build')
curl -s -o paper.jar "https://api.papermc.io/v2/projects/paper/versions/${MC_VERSION}/builds/${BUILD}/downloads/paper-${MC_VERSION}-${BUILD}.jar"
Accept the Mojang EULA (writing this file means you agree to it), then write a start script. The flags are Aikar's flags, the community-standard JVM tuning that keeps garbage-collection pauses short so ticks stay smooth. Match both -Xms and -Xmx to the RAM you are giving this instance; 10G here is an example, leave headroom for the OS.
#!/usr/bin/env bash
cd /home/games/minecraft
echo "eula=true" > eula.txt
exec java -Xms10G -Xmx10G --add-modules=jdk.incubator.vector \
-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 \
-XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch \
-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M \
-XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 \
-XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 \
-XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 \
-XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 \
-Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true \
-jar paper.jar --nogui
Make it executable while still the games user, then return to your admin account for the systemd unit.
chmod +x /home/games/minecraft/start.sh
exit
Write a systemd unit so the server starts on boot and restarts itself if it crashes. It runs as the games user, never as root.
[Unit]
Description=Minecraft Paper server
After=network-online.target
Wants=network-online.target
[Service]
User=games
Group=games
WorkingDirectory=/home/games/minecraft
ExecStart=/home/games/minecraft/start.sh
Restart=on-failure
RestartSec=15
SuccessExitStatus=0 1
[Install]
WantedBy=multi-user.target
Enable and start it, then watch the log until you see "Done".
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
journalctl -u minecraft -f
Because the process runs under systemd, you cannot type into its console directly. To send commands like save-all or op, enable RCON: set enable-rcon=true, a strong rcon.password, and rcon.port=25575 in server.properties. Keep RCON bound to localhost and do NOT open its port in the firewall; reach it with a tool like mcrcon over an SSH session.
enable-rcon=true
rcon.port=25575
rcon.password=CHANGE_ME_TO_A_LONG_RANDOM_STRING
Worked example B: Valheim via steamcmd
Most Steam-based dedicated servers install the same way: through steamcmd, Valve's command-line client. Once you know the pattern, it works for Valheim, Rust, ARK, CS2 and the rest; only the app ID and launch flags change. We use Valheim (server app ID 896660) as the example.
steamcmd is a 32-bit binary, so enable the i386 architecture first, then install it. Accept the Steam licence prompt when apt shows it.
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y multiverse
sudo apt-get update
sudo apt-get install -y steamcmd
As the games user, download the Valheim server. login anonymous works because Valheim's server is free; validate re-checks every file. Re-running this exact command is also how you update the game later.
sudo -u games -i
steamcmd +force_install_dir /home/games/valheim +login anonymous +app_update 896660 validate +quit
Write a start script. Valheim ships its own shared libraries, so the script points LD_LIBRARY_PATH at them and sets SteamAppId to the game (892970). Replace the world name and password with your own; the password must be at least five characters and not part of the server name.
#!/usr/bin/env bash
cd /home/games/valheim
export LD_LIBRARY_PATH="./linux64:$LD_LIBRARY_PATH"
export SteamAppId=892970
exec ./valheim_server.x86_64 \
-name "Server.Biz Valheim" \
-port 2456 \
-world "Dedicated" \
-password "CHANGE_ME" \
-crossplay \
-savedir /home/games/valheim-data
Make it executable, leave the games shell, and add the systemd unit.
chmod +x /home/games/valheim/start.sh
exit
The unit mirrors the Minecraft one: runs as games, restarts on failure, starts at boot.
[Unit]
Description=Valheim dedicated server
After=network-online.target
Wants=network-online.target
[Service]
User=games
Group=games
WorkingDirectory=/home/games/valheim
ExecStart=/home/games/valheim/start.sh
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
Enable, start, and confirm it is up. To update Valheim after a patch, stop the service, run the same steamcmd app_update command as the games user, then start it again.
sudo systemctl daemon-reload
sudo systemctl enable --now valheim
sudo systemctl stop valheim
sudo -u games steamcmd +force_install_dir /home/games/valheim +login anonymous +app_update 896660 validate +quit
sudo systemctl start valheim
Firewall: open only the game ports
A dedicated server has no cloud security group in front of it, so the host firewall is the whole perimeter. Default-deny everything inbound, then open only the ports your games actually use. Minecraft Java listens on TCP 25565; Valheim uses UDP 2456 to 2457. Keep SSH open too, or you lock yourself out.
Set up ufw. The colon in 2456:2457/udp is a port range. Enable it last, after the SSH rule is in place.
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 25565/tcp
sudo ufw allow 2456:2457/udp
sudo ufw enable
sudo ufw status verbose
The firewall stops unwanted connections, but it does nothing against a flood aimed at saturating your uplink. That is a different problem, and it matters for game servers specifically: they are a favourite target of booter services, and a bored player can rent an attack for pocket money. The network here includes 20 Gbit/s of always-on DDoS filtering per server, applied upstream before traffic reaches your box, which absorbs the common volumetric attacks without you doing anything. If you run a large public community or a competitive scene that attracts deliberate, sustained attacks, size the protection up. We cover when and how in the separate DDoS protection guide.
Backups: your worlds are the only thing you cannot rebuild
You can reinstall Paper or rerun steamcmd in minutes. A world that took your community six months to build is gone for good if the disk fails. So back up the save data, on a schedule, to somewhere other than this machine. Minecraft keeps its world under /home/games/minecraft (the world, world_nether and world_the_end folders plus configs). Valheim stores its save in the savedir we set, /home/games/valheim-data, as a .db and .fwl pair.
A nightly tar script. It timestamps each archive, keeps seven days, and deletes older ones. For a fully consistent Minecraft snapshot, run save-off then save-all over RCON before the tar and save-on after; for most communities a nightly hot copy is enough.
#!/usr/bin/env bash
set -euo pipefail
STAMP=$(date +%Y%m%d-%H%M%S)
DEST=/home/games/backups
mkdir -p "$DEST"
tar -czf "$DEST/minecraft-$STAMP.tar.gz" -C /home/games minecraft
tar -czf "$DEST/valheim-$STAMP.tar.gz" -C /home/games valheim-data
find "$DEST" -name '*.tar.gz' -mtime +7 -delete
Make it executable and owned by games.
sudo chown games:games /home/games/backup.sh
sudo chmod +x /home/games/backup.sh
Drive it with a systemd timer instead of cron so failures show up in journalctl. Two small files: a oneshot service and a timer that runs it at 04:00 daily.
[Unit]
Description=Nightly game world backup
[Service]
Type=oneshot
User=games
Group=games
ExecStart=/home/games/backup.sh
The timer.
[Unit]
Description=Run the game backup nightly
[Timer]
OnCalendar=*-*-* 04:00:00
Persistent=true
[Install]
WantedBy=timers.target
Enable the timer and check when it will next fire.
sudo systemctl daemon-reload
sudo systemctl enable --now game-backup.timer
systemctl list-timers game-backup.timer
These archives still live on the same disk, so they only cover fat-finger deletes, not a dead drive. Copy them off the box: rsync to a second machine, or push to a dedicated backup and storage server with big drive bays. A backup you have never restored is a guess, so once a month, pull an archive back and extract one world from it to prove it works.
Running several game servers on one machine
A decent dedicated box has room for many instances. The pattern that scales cleanly keeps each one isolated: its own directory under /home/games, its own port, and its own systemd unit (minecraft-survival.service, minecraft-creative.service, and so on). Give every Minecraft instance a distinct server-port and every Valheim instance its own 2456-plus pair, then open exactly those ports in ufw.
The hard limit is RAM, and you budget it deliberately. Add up the -Xmx of every Minecraft instance plus a rough 2 to 4 GB for each Valheim world, then leave several gigabytes for the operating system and disk cache on top. Do not hand out more heap than you have physical RAM: once the machine swaps, tick times fall off a cliff and every server stutters at once. When you catch yourself managing a dozen units by hand, a panel like Pterodactyl becomes worth considering. It gives you per-game containers, a web UI, sub-user permissions and scheduled tasks. Be clear-eyed about the cost, though: Pterodactyl is a real system to install, secure and keep patched, so you are trading manual unit files for a control plane that is itself now your responsibility. For two or three servers, plain systemd is simpler and has less to break.
Performance monitoring: watch ticks and keep headroom
The number that matters for a game server is not CPU percentage, it is whether the world keeps up with its clock. For Paper, install the spark plugin: /spark tps shows ticks per second (you want a flat 20) and /spark health flags what is stalling the main thread. When TPS dips below 20, players feel it as rubber-banding and delayed hits, long before any system graph looks alarming.
At the OS level, two tools cover almost everything. htop shows per-core load and memory at a glance; watch that no single core is pinned at 100%, because that pinned core is your tick thread. iotop shows which process is hammering the disk, usually the culprit when a save or backup makes the world hitch.
sudo apt-get install -y htop iotop
htop
sudo iotop -o
Aim to keep 20-30% CPU headroom at your normal peak player count. Game load is spiky: a raid, a big redstone contraption, or forty players logging in at once all hit the main thread at the same moment. If you are already near the ceiling on a quiet evening, those spikes turn into visible lag. When headroom disappears for good, that is your signal to move an instance to another box or step up the CPU.
The tradeoff, stated plainly
Your own box gives you stable ticks, no neighbours, and total freedom over mods and instances. The price is that patching, monitoring and backups are now your job, which is exactly what this guide set you up to handle. If your community has outgrown a panel, browse the game-hosting configurations and pick the machine that fits your player counts.
