Minecraft is one of the most popular games ever made — a sandbox game where players explore, build, and survive in procedurally generated worlds. Running your own server gives you full control: custom rules, an allowlist, and a private environment for friends or a small community.
This guide walks you through installing a Minecraft server on Ubuntu 18.04, running it as a systemd service, managing it with the mcrcon RCON console utility, and scheduling automatic daily backups.
<strong>Prerequisite:</strong> You need sudo access. Start by installing the build tools:bashsudo apt update && sudo apt install git build-essential
Minecraft requires Java 8 or higher. Install the headless JRE — it uses fewer system resources and is better suited for server workloads:
bashsudo apt install openjdk-8-jre-headless
Create a dedicated system user for the server. Running Minecraft as root is a security risk. This account has no login password and cannot connect via SSH:
bashsudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft
Switch to the new user and create the working directories:
bashsudo su - minecraftmkdir -p ~/{backups,tools,server} The backups directory stores compressed snapshots, tools holds mcrcon and the backup script, and server contains the Minecraft world and all configuration files.
mcrcon is a lightweight RCON client that lets you run commands on a live Minecraft server from the terminal. Clone and compile it:
bashcd ~/tools && git clone https://github.com/Tiiffi/mcrcon.gitcd ~/tools/mcrcongcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c
Download the official Minecraft server JAR. Check the Minecraft download page for the current URL, then fetch it into the server directory:
bashwget https://launcher.mojang.com/v1/objects/ed76d597a44c5266be2a7fcd77a8270f1f0bc118/server.jar -P ~/server
Run the server once to generate the configuration files. It will exit immediately with an EULA warning:
bashcd ~/server && java -Xmx1024M -Xms512M -jar server.jar nogui
Open ~/server/eula.txt and change eula=false to eula=true to accept the Minecraft EULA. Then open ~/server/server.properties and enable RCON:
rcon.port=25575rcon.password=your-strong-passwordenable-rcon=true
Use a strong, unique password. If you do not need remote console access, block port 25575 at your firewall.
Switch back to your sudo user with exit, then create the service file:
bashsudo nano /etc/systemd/system/minecraft.service
Paste the following:
ini[Unit]Description=Minecraft ServerAfter=network.target[Service]User=minecraftNice=1KillMode=noneWorkingDirectory=/opt/minecraft/serverExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar server.jar noguiExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p your-strong-password stop[Install]WantedBy=multi-user.target
Adjust Xmx (max RAM) and Xms (starting RAM) to match your server. Reload systemd, then start and enable the service:
bashsudo systemctl daemon-reloadsudo systemctl start minecraftsudo systemctl enable minecraft
Open the Minecraft game port in UFW:
bashsudo ufw allow 25565/tcp
Switch to the minecraft user and create /opt/minecraft/tools/backup.sh. The script pauses world saves, archives the server directory with tar, resumes saves, and deletes backups older than 7 days. Make it executable with chmod +x, then schedule it daily in cron:
bashcrontab -e# Add this line to run backups every night at 23:00:0 23 * * * /opt/minecraft/tools/backup.sh
To connect to the live Minecraft console from the terminal:
bash/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p your-strong-password -t
Type Q to exit the console session.
Your Minecraft server is now running on Ubuntu 18.04, managed by systemd, secured under a dedicated user account, and backed up automatically every night. Leave a comment below if you run into any issues during setup.
The file command inspects the actual contents of a file and reports its type — regardless of…
chattr sets and removes special file attributes that operate at the filesystem level, separate from standard…
env prints the current environment, sets or removes variables for a single command, and can start…
nmap (Network Mapper) discovers live hosts, identifies open ports, and detects which service is running…
The id command prints user and group identity for any account on the system. It shows the…
sed processes input line by line, applies your commands, and writes the result to standard output.…