sudo apt install wget screen default-jdk nmap
The minecraft user will have a home directory in /opt/minecraft
sudo useradd -m -r -d /opt/minecraft minecraft
Multiple servers can be run, create a directory for the particular server, folliwng the link below, using “survival”
sudo mkdir /opt/minecraft/survival
go here to find the link to the current server
https://www.minecraft.net/en-us/download/server
sudo wget -O /opt/minecraft/survival/minecraft_server.jar https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
Accept the terms uf the EULA
sudo bash -c "echo eula=true > /opt/minecraft/survival/eula.txt"
Make the minecraft user the owner
sudo chown -R minecraft /opt/minecraft/survival/
Setup systemd startup script by creating a script
sudo nano /etc/systemd/system/[email protected]
And inserting these contents
[Unit] Description=Minecraft Server: %i After=network.target [Service] WorkingDirectory=/opt/minecraft/%i User=minecraft Group=minecraft Restart=always ExecStart=/usr/bin/screen -DmS mc-%i /usr/bin/java -Xmx4G -jar minecraft_server.jar nogui ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN IN 5 SECONDS. SAVING ALL MAPS..."5' ExecStop=/bin/sleep 5 ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"5' ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"5' [Install] WantedBy=multi-user.target
Start the server
$ sudo systemctl start minecraft@survival
Check server status
sudo systemctl status minecraft@survival
Set server to start on boot
sudo systemctl enable minecraft@survival
The server can be stopped with
$ sudo systemctl stop minecraft@survival
Minecraft server settings are in this file
sudo nano /opt/minecraft/linuxconfig/server.properties
User permission settings can be set in the file ops.json, using the following format:
[ { "uuid": "UUID-USER-1", "name": "user1", "level": 4, "bypassesPlayerLimit": false }, { "uuid": "UUID-user-2", "name": "user2", "level": 4, "bypassesPlayerLimit": false } ]
You can find UUIDs for users here https://mcuuid.net/