Complete step-by-step guide for installing and configuring a Minecraft server on Ubuntu, CentOS, and Debian systems.
Published: March 5, 2026 | Author: NGP Hosts Team | Tags: linux server setup tutorial | Reading time: 8 minutes
Setting up a Minecraft server on Linux provides excellent performance, stability, and control over your gaming environment. Whether you're running a small private server for friends or a large public community, Linux offers the reliability needed for 24/7 operation. This comprehensive guide covers everything from Java installation to server optimization.
Before starting, ensure you have:
First, update your system packages to ensure everything is current:
sudo apt update && sudo apt upgrade -y
sudo yum update -y
Minecraft requires Java to run. We'll install OpenJDK 17, which is recommended for modern Minecraft versions.
sudo apt install openjdk-17-jdk -y
sudo yum install java-17-openjdk-devel -y
Verify the installation:
java -version
You should see output similar to:
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8)
OpenJDK 64-Bit Server VM (build 17.0.2+8, mixed mode, sharing)
For security, create a dedicated user for running the Minecraft server:
sudo adduser minecraft
sudo usermod -aG sudo minecraft
Switch to the new user:
su - minecraft
Navigate to the home directory and download the latest Minecraft server JAR file:
cd ~
wget https://launcher.mojang.com/v1/objects/3737db488274a7b21b034b302c1ceaf1c944251e/server.jar
Note: The URL above is for Minecraft 1.20.4. Check the official Minecraft server download page for the latest version.
Start the server once to generate the configuration files:
java -Xmx1024M -Xms1024M -jar server.jar nogui
The server will stop and ask you to agree to the EULA. Edit the eula.txt file:
nano eula.txt
Change eula=false to eula=true and save the file (Ctrl+X, Y, Enter).
Now, let's configure the server properties:
nano server.properties
Key settings to modify:
# Server name
server-name=My Minecraft Server
# Game mode (0=Survival, 1=Creative, 2=Adventure, 3=Spectator)
gamemode=0
# Difficulty (0=Peaceful, 1=Easy, 2=Normal, 3=Hard)
difficulty=2
# Maximum players
max-players=20
# Server port (default 25565)
server-port=25565
# Enable whitelist (true/false)
white-list=false
# Allow flight (true/false)
allow-flight=false
# Spawn protection radius
spawn-protection=16
# View distance (2-32)
view-distance=10
# Server IP (leave blank for all interfaces)
server-ip=
Create a script to easily start your server with proper memory allocation:
nano start.sh
Add the following content (adjust memory values based on your server resources):
#!/bin/bash
# Server startup script
java -Xms2G -Xmx4G -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 server.jar nogui
Make the script executable:
chmod +x start.sh
Open the Minecraft port in your firewall:
sudo ufw allow 25565/tcp
sudo ufw reload
sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --reload
If your server is behind a NAT router, you'll need to forward port 25565:
Run the startup script:
./start.sh
Your server should now be running! You can connect using your server's IP address and port 25565.
For automatic startup on boot, create a systemd service:
sudo nano /etc/systemd/system/minecraft.service
Add the following content:
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/home/minecraft
ExecStart=/home/minecraft/start.sh
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft
Check the service status:
sudo systemctl status minecraft
Adjust memory based on your server size:
Add these JVM arguments for better performance:
-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
# Reduce view distance for better performance
view-distance=6
# Limit entity activation range
entity-broadcast-range-percentage=80
# Optimize chunk loading
max-chained-neighbor-updates=500
# Enable simulation distance (1.18+)
simulation-distance=4
java -versionls -ladf -hsudo ufw statusip addrtelnet localhost 25565free -htopSetting up a Minecraft server on Linux provides excellent performance and reliability for your gaming community. With proper configuration and optimization, your server can handle dozens of players smoothly. Remember to regularly maintain your server, keep backups, and stay updated with the latest Minecraft versions for the best experience.
Looking for free hosting? Try NGP Hosts - No payments required, just community growth!