In short
To set up a Minecraft server on a Linux VDS, install Java 21 on Ubuntu, run the server as a dedicated minecraft user instead of root, download the Paper jar and accept the EULA. Run the server inside tmux as a systemd service so it starts on boot, open only SSH and port 25565 with ufw, and back up the world folders automatically every day with cron.
In this guide
A Linux VDS is one of the most efficient environments for a Minecraft server: the OS uses few resources, everything is controlled from the command line and automation is easy. In this guide, on a VDS running Ubuntu 24.04, we go through installing Java, creating a separate system user, the Paper server, running 24/7 with tmux and systemd, the ufw firewall and automatic backups with cron, in that order. Every command is copy-paste ready.
Requirements
- A VDS running Ubuntu 24.04 with root access. The commands are largely the same on other Debian-based distributions.
- RAM rule of thumb: 4-6 GB of Java memory is enough for a Paper server with 10-20 players and a reasonable plugin count; leave another 1-2 GB for the operating system. For a detailed table, see our article how much RAM does a Minecraft server need.
- An SSH client (on Windows, the
sshcommand in PowerShell is enough).
For a server of this size, the OB-R9-4 Ryzen 9 5900X VDS with 8 GB of RAM is a good starting point: Minecraft's single-core tick loop benefits from high-clock cores.
1. Update the system and install Java
Connect to the server as root:
ssh root@VDS_IP
apt update
apt -y upgrade
apt -y install openjdk-21-jre-headless tmux
java -versionCurrent Minecraft versions require Java 21. If you'll run an older version (e.g. 1.16), install the Java package that version requires; the wrong Java version is the most common reason a server won't start. The -headless package leaves out graphical components, which is the right choice for a server.
2. Create a separate user
Never run a Minecraft server as root. If a vulnerability in a plugin is exploited, the attacker inherits the server process's privileges. A separate, unprivileged user limits that damage:
useradd -r -m -d /opt/minecraft -s /bin/bash minecraft
sudo -iu minecraft
mkdir -p ~/server ~/backups
cd ~/serverSteps 3 and 4 below are done as the minecraft user.
3. Download Paper and run it for the first time
Paper is Spigot-based server software with performance improvements and plugin support. Copy the download link for the version you want from papermc.io/downloads and download it, pasting that link in place of the placeholder:
wget -O paper.jar "KOPYALADIGINIZ_PAPER_BAGLANTISI"
java -Xms2G -Xmx2G -jar paper.jar --noguiThe first run shuts down because the EULA hasn't been accepted. Accept Mojang's EULA and create the start script:
sed -i 's/eula=false/eula=true/' eula.txt
cat > start.sh <<'EOF'
#!/bin/bash
cd /opt/minecraft/server
while true; do
java -Xms6G -Xmx6G -XX:+UseG1GC -jar paper.jar --nogui
if [ $? -eq 0 ]; then break; fi
echo "Sunucu beklenmedik şekilde kapandı, 10 saniye sonra yeniden başlatılıyor"
sleep 10
done
EOF
chmod +x start.shThis script stops when the server shuts down cleanly with the stop command (exit code 0); if it crashes, the script restarts the server after 10 seconds. Keeping -Xms and -Xmx equal prevents memory fluctuation. On an 8 GB VDS, 6 GB leaves enough headroom for the OS and backup tools. For more advanced JVM tuning, see our guide on JVM tuning with Aikar's flags.
4. Quick option: run it with tmux
tmux opens terminal sessions that keep running even if your SSH connection drops. To try the server quickly:
tmux new -s mc
./start.sh- Detach from the session (the server keeps running):
Ctrl+B, thenD - Return to the console:
tmux attach -t mc
You can do the same with screen (screen -S mc; to detach, press Ctrl+A then D). With this method, though, the server doesn't start on its own when the VDS reboots; for a permanent setup, move on to the next step.
5. Permanent option: a systemd service
systemd is Linux's service manager. The service below starts the server inside a tmux session at boot, so you get both automatic startup and console access. As root, create the /etc/systemd/system/minecraft.service file:
[Unit]
Description=Minecraft Sunucusu (Paper)
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=minecraft
WorkingDirectory=/opt/minecraft/server
ExecStart=/usr/bin/tmux new-session -d -s mc /opt/minecraft/server/start.sh
ExecStop=/usr/bin/tmux send-keys -t mc "stop" Enter
ExecStop=/bin/bash -c 'while /usr/bin/tmux has-session -t mc 2>/dev/null; do sleep 1; done'
TimeoutStopSec=120
[Install]
WantedBy=multi-user.targetsystemctl daemon-reload
systemctl enable --now minecraft
systemctl status minecraftTo reach the console, switch to the user with sudo -iu minecraft and type tmux attach -t mc. The systemctl stop minecraft command first sends stop to the server and waits for the world to save, so you don't lose data.
Initial settings and plugins
The server creates the server.properties file on first launch. For performance and security, these are the first lines to check:
max-players: The number of players who can be connected at the same time.view-distanceandsimulation-distance: How many chunks are loaded and processed per player. Lowering them noticeably reduces CPU and RAM load.online-mode: If left attrue, only premium (paid) accounts can join; this is the most robust option for account security.white-list: For a private friends' server, set it totrueand add players one by one.
To add plugins, just copy the .jar files into the /opt/minecraft/server/plugins folder and restart the server. If you copied the files as root, don't forget to give ownership to the minecraft user.
6. Firewall with ufw
ufw (Uncomplicated Firewall) is Ubuntu's simple firewall tool. Remember to allow SSH first; otherwise you'll lock yourself out of the server:
ufw allow OpenSSH
ufw allow 25565/tcp
ufw enable
ufw status- Java Edition players use TCP 25565 by default.
- If you'll also accept Bedrock players through Geyser, add
ufw allow 19132/udp. - If you enable RCON in
server.properties, don't open port25575to the outside.
If you want players to connect with a domain name instead of an IP, add an A record to your domain's DNS settings and, if needed, a _minecraft._tcp SRV record so they can connect without typing a port.
7. Automatic backups with cron
Before a backup, the server must flush in-memory changes to disk and stop writing during the backup; otherwise you may end up with a corrupted backup. The script below does this through tmux. As the minecraft user, create the /opt/minecraft/backup.sh file:
#!/bin/bash
SRC=/opt/minecraft/server
DEST=/opt/minecraft/backups
TS=$(date +%F_%H-%M)
tmux send-keys -t mc "save-off" Enter
trap 'tmux send-keys -t mc "save-on" Enter' EXIT
tmux send-keys -t mc "save-all flush" Enter
sleep 15
tar -czf "$DEST/world_$TS.tar.gz" -C "$SRC" world world_nether world_the_end
find "$DEST" -name 'world_*.tar.gz' -mtime +7 -deletechmod +x /opt/minecraft/backup.sh
crontab -eAdd this line in the editor that opens; a backup runs every night at 04:00 and backups older than 7 days are deleted:
0 4 * * * /opt/minecraft/backup.sh >> /opt/minecraft/backup.log 2>&1The trap line guarantees that saving is turned back on in the server even if the script fails. Also send a copy of your backups to off-server storage with rsync or rclone: after a disk failure or an accidental deletion, the off-site copy is your only way back.
Restoring from a backup
To restore a backup, stop the server, move the current world aside instead of deleting it, and extract the archive:
systemctl stop minecraft
cd /opt/minecraft/server
mkdir -p ../eski_dunya
mv world world_nether world_the_end ../eski_dunya/
tar -xzf /opt/minecraft/backups/world_2026-12-01_04-00.tar.gz -C /opt/minecraft/server
chown -R minecraft:minecraft /opt/minecraft
systemctl start minecraftChange the file name to match your own backup's date. Once the server starts cleanly and you've checked the world, you can delete the eski_dunya folder. Testing your backups this way on a regular basis is the only way to avoid surprises in a real crisis. For plugin data and other backup strategies, see our Minecraft server backup and restore guide.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| UnsupportedClassVersionError | Java version is too old | Install the Java version your game version requires |
| Connection times out | Port 25565 is closed | Check the ufw status output |
| Server suddenly shuts down | Not enough memory; the OS kills the process | Lower the -Xmx value or add RAM |
| Permission denied errors | Files were created as root | chown -R minecraft:minecraft /opt/minecraft |
Next step: the right VDS for your server
This setup scales from a small friends' server to a survival server with dozens of plugins. OB-R9-4 is enough to get started; if you're planning a modpack or a large community, OB-R9-6 with 6 vCPUs and 12 GB of RAM leaves more headroom. You can compare all options on the Ryzen Game VDS plans page. OyunBulut VDS servers are located in Istanbul and come with KVM virtualization, root access and layered DDoS protection.
Frequently asked questions
Which Java version do I need for a Minecraft server on Linux?
Current Minecraft versions require Java 21, which you install on Ubuntu with the openjdk-21-jre-headless package. For older versions, install the Java version that release requires.
Why is it a bad idea to run a Minecraft server as root?
If a vulnerability in a plugin is exploited, the attacker gains the server process's privileges. A separate, unprivileged user limits any damage to that user's files only.
Should I use screen or tmux?
Both keep the server running after SSH disconnects. tmux is more modern and flexible; for a permanent setup, use it together with systemd so the server starts on boot.
Which port needs to be open for a Minecraft server?
Open TCP 25565 for Java Edition. If you accept Bedrock players through Geyser, you also need UDP 19132; the RCON port should not be opened to the outside.
Is it safe to back up while the server is running?
Yes, if you first flush data to disk and pause writes with the save-off and save-all flush commands. The script in this guide does that automatically and turns saving back on with save-on at the end.