Ubuntu is usually the quickest Linux option for a manual Minecraft Java server because the packages you need are available through apt. This guide is for a self-managed server over SSH. If you are using our Minecraft server hosting, use How to create a Minecraft Server instead.
You can run this on a Gaming VPS, VPS, or Dedicated Server. For public servers, leave some spare RAM for the OS and for world generation spikes.
Install Java and tools
- Connect to the Ubuntu server over SSH as a user with sudo access.
- Update apt, then install Java 21 and the small tools used later in the guide:
sudo apt update sudo apt install -y openjdk-21-jre-headless curl jq screen
- Create a clean folder for the Minecraft files:
mkdir -p ~/minecraft cd ~/minecraft
Download and start Minecraft
- Download the current Vanilla server jar from Mojang:
LATEST=$(curl -fsSL https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r '.latest.release') VERSION_URL=$(curl -fsSL https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r --arg VERSION "$LATEST" '.versions[] | select(.id == $VERSION) | .url') SERVER_URL=$(curl -fsSL "$VERSION_URL" | jq -r '.downloads.server.url') curl -fLo server.jar "$SERVER_URL"
If you want a specific Minecraft version instead of the latest release, set VERSION to the version you want, then download the matching server jar:
VERSION="1.21.1" VERSION_URL=$(curl -fsSL https://piston-meta.mojang.com/mc/game/version_manifest_v2.json | jq -r --arg VERSION "$VERSION" '.versions[] | select(.id == $VERSION) | .url') SERVER_URL=$(curl -fsSL "$VERSION_URL" | jq -r '.downloads.server.url') curl -fLo server.jar "$SERVER_URL"
- Start the server once so it creates eula.txt, then let it stop:
java -Xms1G -Xmx2G -jar server.jar nogui
- If you agree to the Minecraft EULA, update the file:
sed -i 's/eula=false/eula=true/' eula.txt
- Start Minecraft inside screen so it keeps running after you close SSH:
screen -S minecraft java -Xms1G -Xmx2G -jar server.jar nogui
- Press CTRL + A, then D to leave the screen session running in the background.
Firewall and console access
- If this Ubuntu server uses UFW, allow the default Minecraft port. Your firewall may be different, so use the rule that matches your server:
sudo ufw allow 25565/tcp
- Return to the Minecraft console later with:
screen -r minecraft
Players can connect using your server IP and port 25565. If you change the server port in server.properties, give players the new IP:port instead.
This Ubuntu setup gives you full control, but it also means you need to manage backups, updates, firewall changes, Java issues, and restarts yourself.
