Installing And Updating A Minecraft Server On Ubuntu

30th November, 2016 by

Minecraft is one of the most popular computer games of recent years. One of the great features is the ability to play with other people online through the use of a web server. Unlike the Minecraft game itself, the server software is free to download and use so anyone can host a server. Installation is pretty simple as the Minecraft server is a Java application. Read below how to create a Minecraft server of your own on Ubuntu:

Installing Java

The first thing you need to do is install Java. There’s no official installer from Canonical for Java in Ubuntu so you need to use an external PPA. Fortunately, the WebUpD8 team provides one:

sudo apt-add-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java8-installer

Running Minecraft

Once this is installed we need to set up the user to run Minecraft. It’s best to use a specific user for the task that isn’t able to log in and doesn’t have any sudo privileges.

sudo useradd minecraft

sudo mkdir /home/minecraft

With the user created we can create a directory to store the minecraft files:

sudo mkdir /usr/local/games/minecraft

Set ownership of that directory to the minecraft user and change to that user:

sudo chown minecraft:minecraft /usr/local/games/minecraft

cd /usr/local/games/minecraft

sudo su minecraft

The latest version of Minecraft Server can now be downloaded. Version 1.10.2 is the current version as I write this post, but check here for the newest link in future:

wget -O minecraft_server.jar

To run the server run the following command:

java -Xms1G -Xmx1G -jar minecraft_server.jar nogui

Be aware that this will fail the first time with a note that you need to look at the file eula.txt. Therefore you need to edit that file and change the value false to ‘true’ in order to agree with the End User License Agreement for Minecraft. To do this use the following command:

nano eula.txt

You can then start the server again to check it all starts up. Once it does, you can use the command /stop to exit the server:


Once that’s done, you need to exit the minecraft user’s session:


Startup Script For Minecraft

Next, we need to make a startup script for Minecraft so that it will boot when the server restarts. You can find this script at Don’t use the wget link they provide as that seems to leave spaces at the start of each line which will break things. So we’ll copy and paste the script code into our own file:

sudo nano /etc/init.d/minecraft

Copy and paste in the script text from the above link. Once complete, we need to change a few of the variables at the top of the script as follows:



Executing The File

With those changes made, save and exit the file. Now we need to make it executable:

sudo chmod +x /etc/init.d/minecraft

To make it start automatically at boot:

sudo chkconfig minecraft on

Finally, you can start the server using the init script:

sudo /etc/init.d/minecraft start

Backing Up Minecraft

Updating Minecraft is pretty simple from this point. You will just need to back up the current Minecraft directory, and then download the latest version as before.

To backup stop minecraft and copy the files:

sudo /etc/init.d/minecraft stop

sudo cp -r /usr/local/minecraft ~/minecraftbackup-$(date +%Y-%m-%d)

Get the update and then start minecraft again:

sudo su minecraft

wget -O /usr/local/games/minecraft/minecraft_server.jar


sudo /etc/init.d/minecraft start

Note that in the example above we used the same version of Minecraft in the update example. You can get the link to download the latest version of Minecraft from the official server download page linked above.