How to update your Minecraft server
Update the Minecraft Server to the latest version.
Learn how to update your Minecraft server to the latest version on Ubuntu 21.04 without losing any data or overwriting your world file. The Minecraft server must be updated manually when Mojang issues a new Minecraft update.
Create backups and download the new version
Before we are going to update the server to the latest version, we are going to make a backup just in case.
Change to your minecraft root directory.
Create a backup of your world file.
sudo cp -r world world-backup
Next, we need to create a backup of your working server.jar file.
sudo cp server.jar server.jar-backup
Now go to the Minecraft server download page and copy the url to download the latest version of minecraft. Download the version with the following command.
sudo wget [URL]
As an example we will be using version 1.18.1
sudo wget https://launcher.mojang.com/v1/objects/125e5adf40c659fd3bce3e66e67a16bb49ecc1b9/server.jar
Stop the Minecraft server and upgrade
To stop the session simply type stop while in the Minecraft server console. When using a screen session. You can attach to the screen session using the following command.
Same goes for the screen session, simply type stop. Or use CTRL + C to stop the session.
Now we need to move the new server.jar file to the old one. Use the following command.
sudo mv server.jar1 server.jar
You can now start the server again.