How to setup a Java Minecraft server on Ubuntu / Debian Linux (2023, 1.20.2)

Have you ever wanted to set up a Java Minecraft server for you and your friends, but the task of setting one up on a Linux server seems too daunting? This guide will walk you through the simple setup of setting up a Java Minecraft server on Ubuntu Server, or Debian Linux.

Step 1: Choose your Linux operating system distribution

I would personally recommend Ubuntu Server 22.04 LTS, as it has up to date packages, gets fast security updates, and has 5 years of guaranteed security updates. If you decide to use Debian, this tutorial will still work.

Step 2: Updates

You should install any system updates that are required, to ensure your server is up to date and secure. Run the apt commands below to do this

sudo apt update

sudo apt upgrade -y

These commands will check for, and install updates, respectively. Once they are complete, you can reboot your system using:

sudo reboot now

Step 3: Install required tools and dependencies

You need a couple of things installed on your system before you can run Minecraft server. You can install them with the command below:

sudo apt install screen openjdk-17-jre-headless -y
  • Screen: A terminal multiplexer (Required so you can leave the terminal session without closing the server)
  • OpenJDK: The Java runtime required for the Minecraft server

Step 3: Download Minecraft server

To download the Minecraft server 1.20.2 executable from minecraft.net, run the commands below:

mkdir Minecraft && cd minecraft
curl -o minecraft.jar https://piston-data.mojang.com/v1/objects/5b868151bd02b41319f54c8d4061b8cae84e665c/server.jar

Step 3: First run and accepting the EULA

When you run the server for the first time, the server will exit and force you to accept the EULA. This is perfectly normal and expected

java -Xmx1024M -Xms1024M -jar minecraft.jar nogui
nano eula.txt

Change the line from eula=false to eula=true

To exit nano press Ctrl + X and then press Y, then Enter to save the file

Step 4: Editing the server properties

To edit the server properties, open the file server.properties with the command below:

nano server.properties

You can read what each value does on the Minecraft wiki

Step 5: Finally running the server

Before running the server, you need to decide how much memory you are going to assign to your Minecraft server. You need to leave some for the operating system. I generally recommend leaving about 250 to 500 MB free. You can set this with the -Xmx flag. I’m going to use 3500MB (3.5 GB) as my example. Don’t adjust the -Xms flag as it can make the server unstable in some cases, and does not affect performance after the initial startup

screen

Press enter to dismiss the welcome message

java -Xmx3500M -Xms1024M -jar minecraft.jar nogui

If you want to leave the console, you can detach from the screen session with Ctrl + A + D and it’ll keep running. Without screen, the server would stop once you closed the terminal session

To access the server from a new terminal session, reattach screen to it with:

screen -r

Step 6: Connect to the server in Minecraft

Open Minecraft, and open the “Multiplayer” option. Then click add server, and enter the IP address or hostname for your server

Conclusion

That’s it. You’ve now created a Minecraft server that you and your friends can play on. For more tips, you can look at our server category for more posts to help you run and maintain your Minecraft server!


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *