In short: install Java (25 for Paper 26.x, 21 for 1.21.x), create a minecraft user, put Paper in /opt/minecraft, run it once and accept the EULA. Then keep the console in tmux and let systemd handle autostart — the server survives a reboot of the machine and shuts down through stop, without losing unsaved chunks. The last step is opening the game port in the firewall.
What you need
- A VPS or dedicated server with Ubuntu or Debian and SSH access with
sudo. How to pick the machine: hosting or VPS. - A free TCP port for the game — 25565 by default — and the SSH port.
- An idea of how much memory to give the server: Paper advises leaving the OS about 1–1.5 GB spare; more in how much RAM a server needs.
Step 1. The system and a dedicated user
Update the packages and create a system user for the server. A server started as root gets rights over the whole machine — and so does every plugin it loads. A dedicated user limits the damage if a plugin turns out malicious or vulnerable.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y tmux curl jq
sudo adduser --system --group --home /opt/minecraft minecraftStep 2. Java
Paper's docs install Java from the Amazon Corretto repository. Paper 26.1 and newer needs Java 25, 1.20–1.21.11 needs Java 21. Skip packages with a headless suffix: they lack dependencies Paper needs.
sudo apt-get install -y ca-certificates apt-transport-https gnupg wget
wget -O - https://apt.corretto.aws/corretto.key | sudo gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | sudo tee /etc/apt/sources.list.d/corretto.list
sudo apt-get update
sudo apt-get install -y java-25-amazon-corretto-jdk libxi6 libxtst6 libxrender1
java -version # the first line should start with openjdk 25For a 1.21.x server, install java-21-amazon-corretto-jdk from the same repository. The full Java table is in how to make a Minecraft server.
Step 3. Paper and the first start
Download a build from Paper's downloads page or with a script through PaperMC's downloads API. The API requires a User-Agent header naming your software and a contact — it rejects curl's default header.
VERSION=1.21.11
UA="my-server-setup (admin@example.com)" # PaperMC's API wants your name and a contact
URL=$(curl -s -H "User-Agent: $UA" \
"https://fill.papermc.io/v3/projects/paper/versions/$VERSION/builds" \
| jq -r 'map(select(.channel == "STABLE")) | .[0] | .downloads."server:default".url')
curl -H "User-Agent: $UA" -o paper.jar "$URL"#!/bin/sh
cd /opt/minecraft
exec java -Xms4G -Xmx4G -jar paper.jar --nogui- 1
Make the script executable
sudo chmod +x /opt/minecraft/start.sh && sudo chown -R minecraft:minecraft /opt/minecraft. - 2
Run the server once
sudo -u minecraft /opt/minecraft/start.sh— it createseula.txtand stops. - 3
Accept the EULA
Set
eula=truein/opt/minecraft/eula.txt— that confirms you agree to the Minecraft EULA. - 4
Check the start
Run
start.shagain, wait forDonein the console, then shut the server down withstop.
Step 4. The console in tmux
A server started right in an SSH session stops as soon as you disconnect. tmux keeps the console in the background: you can disconnect and come back to the same console later.
| Action | Command |
|---|---|
| Open the server console | sudo -u minecraft tmux attach -t mc |
| Leave without stopping the server | Ctrl+B, then D |
| Send a command without opening the console | sudo -u minecraft tmux send-keys -t mc "say Restart in 5 minutes" Enter |
| See whether the session is running | sudo -u minecraft tmux ls |
mc session is created by the systemd unit in the next stepStep 5. Autostart with systemd
systemd starts the server when the machine boots and brings it back if the process ends. The unit below creates a tmux session with the server, and on stop it sends stop to the console and waits until the server has saved its worlds and exited. Without that wait, systemd would kill the process before the chunks were written.
[Unit]
Description=Minecraft server (Paper)
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=minecraft
WorkingDirectory=/opt/minecraft
# the server console lives in the tmux session "mc"
ExecStart=/usr/bin/tmux new-session -d -s mc /opt/minecraft/start.sh
# "stop" saves the worlds; wait until the server is down and the session closes
ExecStop=/bin/sh -c 'tmux send-keys -t mc "stop" Enter; while tmux has-session -t mc 2>/dev/null; do sleep 1; done'
TimeoutStopSec=180
# crashed, or stopped with "stop" in game: start again after 10 seconds
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now minecraft
sudo systemctl status minecraft
sudo systemctl restart minecraft # restart
sudo systemctl stop minecraft # clean shutdown through stopStep 6. The firewall
sudo ufw allow 22/tcp
sudo ufw allow 25565/tcp
sudo ufw enable
sudo ufw status verboseAllow SSH first, then enable the firewall — otherwise you lock yourself out. Don't open RCON or query to the internet. Ports, checking from outside and SRV records are covered in server IP and port.
Maintenance
- System updates.
sudo apt-get update && sudo apt-get upgradeweekly; a new Linux kernel takes effect after a reboot. - Paper updates. Stop the server, replace
paper.jarwith the new build and start it. Plugins are easiest to update throughplugins/update— see Paper. - Logs. The current run's log is
/opt/minecraft/logs/latest.log; the unit's own events are injournalctl -u minecraft. Reading crashes: logs and crash reports. - Backups. The script with
save-off, an archive and cron from server backups works with the samemcsession.
An anticheat on a VPS
On your own VPS you decide what runs on the server. DGuard is the best anticheat for a modern Minecraft server: it goes into plugins/ next to the latest PacketEvents release, and the key from the panel goes into plugins/DGuard/config.yml. It needs no inbound ports, only outbound HTTPS to DGuard's site — that's where the cloud check with the AI Combat neural network runs. DGuard is free up to 30 players online.
FAQ
How do I keep a Minecraft server running after closing SSH?
Run it in tmux or screen, and for autostart as a systemd service. A server started right in an SSH session stops with it.
Which Java should I install on Ubuntu for a Minecraft server?
Per Paper's docs: Java 25 for 26.1 and newer, Java 21 for 1.20–1.21.11. Paper installs it from the Amazon Corretto repository; headless packages won't do.
Can I run a Minecraft server as root?
Technically yes, but don't: the server and every plugin get rights over the whole machine. Create a dedicated user and run the server as that user.
How do I shut the server down cleanly under systemd?
With sudo systemctl stop minecraft, as long as the unit sends stop to the console and waits for the exit, as in the example above. The server then saves its worlds and disables plugins.
Where do I see server errors on Linux?
In logs/latest.log in the server folder and in journalctl -u minecraft for the service's own events. Minecraft's crash reports are in the crash-reports folder.
Sources
- Paper: installing Java (Corretto)
- Paper: Getting started
- PaperMC: downloads API (Fill v3)
- systemd.service: ExecStart, ExecStop, Restart, TimeoutStopSec
- tmux(1): new-session, send-keys, has-session
- Ubuntu Server: the ufw firewall
- Minecraft EULA
- DGuard, the best anticheat for a modern Minecraft server: checks compared with GrimAC, Vulcan, Polar, Intave and Matrix
- DGuard: installation, requirements and troubleshooting
- DGuard: supported Paper and Leaf versions