Raspberry Pi Tutorial: Host a Minecraft server on Ubuntu Desktop

Oliver Smith

on 9 December 2021

This article was last updated 2 years ago.


Welcome to the second in our series of Linux gaming posts in the run up to the holidays. This week, we’ve put together a tutorial that teaches you how to create a basic Minecraft Server on a Raspberry Pi with Ubuntu Desktop, so you can play locally with your friends.

This is a great afternoon project to work on with a friend or family member!

Hosting a Minecraft server unlocks a tonne of additional control over how you play Minecraft with your friends. You can change the game rules and difficulty, the behaviour of enemies and determine how players interact.

Setting up a server is also a great way to learn more about Linux. Linux is all about tinkering and trying new things. While it can seem intimidating at first, the instructions you’ll follow for this project will help you approach more complex Linux projects in the future!

In this tutorial, we’ll be using a Raspberry Pi 4 4GB with a 32GB SD card, but you can also follow along on pretty much any laptop or PC that has Ubuntu Desktop installed. You could even use a Virtual Machine.

Check out these tutorials for getting started with Ubuntu Desktop on these platforms:

Note: We’ll be using Ubuntu Desktop 21.10 for Raspberry Pi in this tutorial, and recommend you follow along with Ubuntu Desktop 21.10 on whatever device you use.

Of course, you’ll also need another PC or laptop with Minecraft Java Edition installed so you can connect to your server once you’ve created it!

Let’s jump in.

Install Ubuntu on your Raspberry Pi and update

If you’ve followed the Raspberry Pi installation tutorial, you’ll be pretty much ready to go, but whenever we start a new project, it’s always important to make sure everything is up to date.

Go ahead and open a terminal (ALT+T or click the Terminal icon in your sidebar) and type:

sudo apt update
sudo apt upgrade

Enter your password and press Y when prompted.

This will check whether your version of Ubuntu is up to date and download and install any new packages.

Install Java

Minecraft servers are based on Minecraft Java Edition, the original version of Minecraft, so our next step is to install Java on our Raspberry Pi. The default Java on Ubuntu is older than the one used for Minecraft Servers, so we need to specifically install the latest Java Runtime Environment (jre), which is version 18:

sudo apt install openjdk-18-jre

Type your password and press Y when prompted.

Create a folder for your server

Now you need a place to put the Minecraft server on your Pi. We could do it the ‘Windows’ way by opening the file manager, right-clicking, and creating a New Folder named Minecraft. But we’re already in the terminal, so let’s keep typing here!

mkdir Minecraft/

The above will do exactly the same thing as using the file manager. In fact, you can check the file manager yourself to confirm that the new folder has appeared!

These two actions do the same thing!

Since we’re going to install our server inside the new folder, we need to tell our terminal that we’re going to work there. 

If you type

ls

You can see that we’re still in the home directory of our PC. You’ll see your Documents and Downloads folders, as well as the new Minecraft folder you created. To get inside this folder, we need to Change Directory (cd), so type:

cd Minecraft/

If you type ls again, you can see that now nothing is returned, because we’re inside an empty folder. You’ll also see that your prompt now includes the Minecraft folder name:

Download Minecraft Server!

Leave your terminal open, but now you also need to open your web browser.

In your browser, go to this page: https://www.minecraft.net/en-us/download/server

We want to download the server linked here, but instead of left-clicking it, let’s RIGHT-CLICK and select Copy Link.

This will make sure you always get the latest version of the server when following this tutorial!

Leave that page open, as we’ll come back to it shortly. Now go back to the terminal window, making sure we’re still in the Minecraft folder, and tell the terminal to download the server to this folder.

Type: 

wget

And then RIGHT-CLICK and Paste the link to the server. It should look something like this:

Then press ENTER. This command instructs your Pi to ‘get’ (download) whatever file is linked at that web address you gave it.

You will see the download complete, and if you then type:

ls

You’ll see we now have a server.jar file in our Minecraft folder!

Start your server!

Go back to https://www.minecraft.net/en-us/download/server, and this time copy the Java instructions listed into your terminal.

java -Xmx1024M -Xms1024M -jar minecraft_server.1.18.jar nogui

Press ENTER and… Error??

That’s because we just told our Pi to run a file called minecraft_server.1.18.jar, but you can see from our last ls that when we installed the server it was just called server.jar.

That’s an easy fix. 

If you press UP on the keyboard, your last instruction will be repeated. Do that now, and then edit the filename to server.jar and press ENTER again.

java -Xmx1024M -Xms1024M -jar server.jar nogui

Success!

Sort of. Now we have another error. We need to agree to the End User License Agreement (EULA) before we can get started.

So where’s the EULA?

Well let’s use our trusty

ls

on our Minecraft directory one more time. You’ll see the installation process has created a set of new files. This is good, because these files are what allows us to play around with the game rules! But before we can get to the fun stuff, let’s sign the EULA.

We can do this directly in the terminal (you can do everything in the terminal, that’s why it’s so cool) using a text editor called nano. Type:

nano eula.txt

This will open the eula.txt file in your terminal window. Now you just need to change the eula line to true instead of false.

Then we press CTRL+S to save and CTRL+X to exit back to the Command Line.

Let’s try the server again!

If you press UP a few times on your keyboard, we can repeat the instruction from earlier without typing it out again.

But let’s make one last change before we run things and double the -Xmx1024M and -Xms1024M in our command to -Xmx2048M and -Xms2048. Xmx and Xms refer to the amount of memory the server will use. The more we give it, the better the performance.

java -Xmx2048M -Xms2048M -jar server.jar nogui

Now we press ENTER again and the server should start properly!

This next bit is going to take a while. And you probably won’t be able to browse Facebook whilst you’re waiting, as most of the Raspberry Pi will be focussed on standing up the server.

Once your server has finished setting up, you’ll probably get a few messages like this depending on how much memory you assigned it in the previous command. It’s normal to have a few of these at startup whatever happens, so don’t worry too much.

Top Tip: Better hardware means a better server. If you’re considering keeping your server around, or using it with a lot of people, an 8GB Raspberry Pi 4 (with increased Xmx and Xms numbers) will perform better. Attaching an SSD via a USB3.0 port will also help.

Eventually, as players join, you’ll be able to see key events appear on the terminal as they happen in the game world.

Ouch.

You can stop your server any time by typing 

stop

in the Terminal. This will also save your world so you can resume again at a later time.

Joining the Minecraft server over your local network

If you’ve invited your friends to join your server on their laptops, they’re probably a bit impatient to get going by now. But we’re finally ready!

On your (or your friend’s) laptop or PC, make sure you are running the Java Edition of Minecraft (which you can install from the official Minecraft site – just download it and double-click).

Then they need to navigate to Multiplayer > Direct Connection.

Now they need to enter the local IP address of the server which is… hmmm. We don’t know.

Let’s go back to our server terminal!

To find out the server’s local IP, you need to open a second terminal window, or a new tab in the current terminal (or just stop your server for this bit and restart it after).

Type:

hostname -I

This will produce a string of numbers, but you only need the first set.

Looking at the above, my local IP is 192.168.1.222. Yours will be similar but not the same.

So that’s what my guests should add in their games:

Once your guests have entered your server IP, they just need to click Join Server and they’re in!

Unfortunately for my server, I spawned right next to a spider. And it was raining.

Modifying your Server Settings

If you want to play regular Minecraft locally with your friends, then you’re all done – congratulations! But the best part of running a server is that you can play god with the game world!

Let’s close the server (stop, remember?) and do some tweaking.

This time, we want to do the same thing as we did to sign the EULA but this time we’re going to edit a file called server.properties (you might have spotted it the last time we used ls).

Type:

nano server.properties

This should bring up all the configuration options for your server. If you scroll down there’s quite a few!

I won’t go into detail on every option, but you can read about them on the Minecraft Wiki.

Personally, I just want to turn off the spiders and change the server’s message of the day, so I’m going to make the following tweaks:

spawn-monsters=false
motd=Welcome to Minebuntu

Just as before, we press CTRL+S and then CTRL+X to save and exit!

Top Tip: If you want to start a new Minecraft server, just delete the World folder from your Minecraft directory, or rename the level-name in server.properties. This will create a new gameworld folder with the updated name next time the server starts, and you can switch back to the old one any time!

Connecting to your Minecraft server remotely

In this project, we’ve shown you how to set up and customise a Minecraft server on your Raspberry Pi 4, and how players on the same Wi-Fi network can connect locally to your gameworld.

You’ve also learned some handy Linux commands, like ls, nano, and mkdir!

But what if your friends want to connect remotely, from their own homes?

When we think about players connecting over the internet, we need to talk about more advanced concepts like port forwarding. We also need to consider security and what internet strangers could do if they gained access to your Raspberry Pi. 

If you’re not an advanced Linux user, we recommend finding one to help you with this side of things, as we won’t be able to tackle those issues today!

That’s it, you’ve completed the Raspberry Pi tutorial!

We hope you found this guide useful, and we’re always looking to hear from gamers and Raspberry Pi users about their experiences with Ubuntu.

If you have any feedback, suggestions for other gaming or Pi tutorials, or tips on getting started for new users, let us know your thoughts in the Ubuntu Desktop Discourse (or our brand new Raspberry Pi Discourse).

We’d love to hear from you!

As usual, you can keep up to date on all things Ubuntu Desktop on our blog.

rapsberry pi logo

Ubuntu Desktop for Raspberry Pi

Watch the live event of the 20.10 launch the and find out all the news about the new Ubuntu Desktop image for Raspberry Pi.

Discover more ›

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Announcing Authd: OIDC authentication for Ubuntu Desktop and Server

Today we are announcing the general availability of Authd, a new authentication daemon for Ubuntu that allows direct integration with cloud-based identity...

Meet Canonical at Open Source Summit Europe 2024

Join Canonical, the publisher of Ubuntu, as we attend the upcoming Open Source Summit Europe 2024 in Austria. Hosted by the Linux Foundation, this summit is...

Canonical releases Landscape 24.04 LTS

Landscape 24.04 LTS is Landscape’s first LTS release, with a modernised backend, web portal, snap management, and repository management features.