VER=1.18.1
Mojang offical minecraft server:
MANIFEST="https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"
META_URL="$(curl -sL "$MANIFEST" | jq -r --arg v "$VER" '.versions[] | select(.id==$v) | .url')"
SERVER_URL="$(curl -sL "$META_URL" | jq -r '.downloads.server.url')"
curl -L -o "server-$VER.jar" "$SERVER_URL"
PaperMC minecraft server (recommended):
curl -L -o paper.jar \
"https://api.papermc.io/v2/projects/paper/versions/1.18.1/builds/216/downloads/paper-1.18.1-216.jar"
Then run it once which will fail because of the EULA:
java -Xms512M -Xmx1024M -jar paper.jar nogui
Next step is to accept the EULA:
sed -i 's/eula=false/eula=true/' eula.txt
Then run the minecraft server again which will you can then connect to after it finishes generating the world:
java -Xms512M -Xmx1024M -jar "server-1.18.1.jar" nogui