Site icon Linux Genie

How to Create a Minecraft Server on Ubuntu 24.04

Intall minecraft on Ubuntu

Having your own Minecraft server offers several benefits, including the ability to customize your world, use mods, set custom rules, and play with like-minded people.

There are two main Minecraft editions; Java and Bedrock. Both editions have different server setup instructions. In this tutorial, I will explain the process of configuring a Minecraft server on the most recent version of Ubuntu, version 24.04 known as Noble Numbat. The guide is divided into two sections: one for setting up a server on Java edition and the other for Bedrock edition.

Before we proceed further, It’s important to ensure that all necessary components and conditions are met to set up the Minecraft server on Ubuntu.

Prerequisites

To prepare for setting up a Minecraft server, you must satisfy the following prerequisites:

Operating System: Ubuntu 24.04 Server

User: Non-root user with sudo privileges

Application: Java Runtime Environment (JRE) and Screen

Hardware: Minimum 4GB of RAM (8GB Recommended)

Internet: Preferably a good wired internet connection. Note that, Minecraft consumes 100MB per hour per user.

Setting Up a Minecraft Server on Ubuntu (Java Edition)

To download and configure the Minecraft server on Ubuntu, go through the steps given below:

Step 1: Install Java

The first step is to install Java on Ubuntu which is one of the requirements. The LTS version of JRE by the time I am writing this guide is 17.

sudo apt install openjdk-17-jre-headless

The headless JRE is the minimal version of Java, which is sufficient to set up a Minecraft server. The headless means without the graphical interface.

Now, let’s verify the Java version:

java --version

Step 2: Install Screen

Next, you need to install the Screen utility which is used to manage multiple terminal sessions. Using the Screen tool, you can run the terminal sessions in the background by detaching it.

sudo apt install screen

This tool is crucial because closing the terminal session also shuts down the Minecraft server. It will detach the Minecraft server session and run it in the background.

Step 3: Configure UFW for Minecraft Server

To make the server accessible for the players, it is important to allow incoming traffic to the Minecraft server on 25565. To allow this port through the file use the command given below:

sudo ufw allow 25565

 

Step 4: Download the Minecraft Server

Download the Minecraft server file from this link or use the wget command.

wget https://piston-data.mojang.com/v1/objects/8dd1a28015f51b1803213892b50b7b4fc76e/594d/server.jar

You can access the latest Minecraft server by navigating this link. However, you can also download the older version of Minecraft sever by visiting this link.

The server file, named server.jar, will be downloaded into the current working directory where you initiated the download.

Step 5: Running Minecraft Server

Before running the Minecraft server, create a screen session:

screen

Start the session, press the space key.

Run the Minecraft server using the java utility.

java -Xmx1024M -Xms1024M -jar server.jar nogui

In the above command:

-Xmx1024M is setting up the initial heap size to 1024 MB or 1 GB. It can be raised and adjusted based on your preference.

-Xms1024M is setting up the maximum heap size to 1024 MB, however, it can also be increased.

-jar option is used to run the jar file which is server.jar in this case.

nogui is used to run the server without the GUI.

-Xmx

 

Memory limit, the Java process starts with

 

-Xms

 

Memory limit, the Java process can use

Running the server the first time will through the Failed to load eula.txt error.

Running the above command will generate a few files and folders and one of them is eula.txt.

Open the eula.txt file in the nano text editor.

sudo nano eula.txt

Set the eula=false to eula=true and save the file using ctrl+S and exit the editor using ctrl+X.

Now, restart the server.

java -Xmx1024M -Xms1024M -jar server.jar nogui

As it can be seen the Minecraft server is successfully configured on Ubuntu and started. To get more help with the server, simply type help and press Enter.

To move the Minecraft server process in the background, we need to detach this Screen terminal session. Press ctrl+A+D and you will get the output shown in the image below.

This means the session has been detached. To list the screen session, use the screen command with the -list option.

screen -list

To get back the session, use screen -r with the session ID which is 1091 in this case.

screen -r 1091

The -r in the above command indicates reattach.

Accessing Minecraft Server

To access the Minecraft servers, read the steps given below:

Step 1: Get the Server IP

To access the server first get the IP address.

ip a

Note the server IP. It can also be accessed using ifconfig command.

Step 2: Launch the Minecraft Client

The Minecraft game will be served as a client. Open the Minecraft Java Edition.

Step 3: Open Multiplayer Options

On the main menu, click on the Multiplayer:

Step 4: Add the Server

Now, click on the Add Server button.

Give a name for the server and specify the IP address of the server where you intend to host the Minecraft game.

Click on Done to initiate the connection process and allow you to access the server for gameplay.

The output shows that the player is connected to Minecraft successfully.

Step 5: Join the Server

Select the server, then at the bottom click on the Join Server button to launch the game.

The player will be spawned in the Minecraft world.

Note: The server versions are backward compatible; if you are using an older version of the server then the updated version of Minecraft will not connect to the server.

Run Minecraft Server on Boot

Instead of running the Minecraft server every time you log in to Ubuntu, it is recommended to configure the server to run on boot.

There are two methods to start the server on boot:

  • Using cron job
  • Using Systemd

Due to the limitation of cron job, it is recommended to configure a Systemd service. Below are the instructions to configure Ubuntu for automatically running a Minecraft server upon system boot.

Step 1: Create a Service File

Use the nano editor and create a minecraft.service file.

sudo nano /etc/systemd/system/minecraft.service

And add the lines given below:

[Unit]

Description=Minecraft server

Wants=network.target

[Service]

User=minecraft

Group=minecraft

Restart=on-failure

WorkingDirectory=~

ExecStart=/usr/bin/java -Xms1024M -Xmx1024M -jar server.jar --nogui

[Install]

WantedBy=multi-user.target

Save the file.

Step 2: Enable the Server to Run on Boot

Now, reload the daemon using the systemctl.

sudo systemctl daemon-reload

And enable it.

sudo systemctl enable Minecraft.service

Managing Minecraft Server

The Minecraft Server can be managed by modifying the server.properties file. This file appears after the first launch of the server.

Open the file in any text editor, a list of options will appear.

sudo nano server.properties

As a server administrator you can manage various options to set custom gameplay for the joiners. Some important server properties are listed below:

difficulty: The default is set to be easy; other options are peaceful, normal, and hard.

enable-command-block: It allows players to use Minecraft commands. The default is set to false, set to true to enable it.

enforce-secure-profile: Only a player with a Mojang public key can join the server. The default is set to true.

gamemode: The default game mode is set survival, it can be set to creative, adventure, and spectator.

max-players: The maximum number of players, default is set to 20. It can be changed; however, it is important to note that a greater number of players consumes more resources.

motd: To set a message to appear in the servers list under the server’s name, use this option.

pvp: By default, this setting is configured to true, allowing players to engage in player-versus-player combat and eliminate each other in the game. If set to false then they cannot kill other players.

white-list: To let only specific players connect to the server if set to true. The default is false, which means anybody can connect to the server.

spawn-protection: It indicates the number of blocks or areas around the player that are protected when it respawns. The default is set to 16. Setting it to 0 will disable the spawn protection. The formula to calculate the protected area is given below:

spawn-protectionx2+1 x spawn-protectionx2+1

Setting Up a Minecraft Server on Ubuntu (Bedrock Edition)

To set up a server for the Minecraft Bedrock edition is relatively simple. The steps to configure the Minecraft server for Bedrock Edition are given below.

Note: The Minecraft Bedrock comes with its own version of Java, so it is not necessarily required to install.

Step 1: Download the Server

First of all, download the server file from the provided link. Or if you are using Ubuntu without the GUI then use the wget utility to download it:

wget https://minecraft.azureedge.net/bin-linux/bedrock-server-1.20.73.01.zip

The file will be downloaded to the directory where you are currently working.

Step 2: Extract the Server File

Create a folder in which the Bedrock server files will be extracted.

sudo mkdir mc_bedrock_server

Extract the zip file in this folder using the unzip utility.

sudo unzip bedrock-server-1.20.73.01.zip -d mc_bedrock_server

Step 3: Launch the Server

Now, navigate to the extracted folder.

cd mc_bedrock_server

Execute the following command to run the Minecraft Bedrock server:

LD_LIBRARY_PATH=. ./bedrock_server

Note: While executing the server command you may encounter an error saying it cannot be executed binary file: Exec format error. This error emerges because you are running the file on the ARM version of Ubuntu. The Minecraft Bedrock server is currently unavailable for ARM architecture, it can only run with x86_64 devices.

Like Java edition, the Bedrock server also comes with a server.properties file to manage it. You can open it in the nano editor to change the server’s settings.

Minecraft Servers Hosting Platforms Recommendation

There are two ways to host the Minecraft servers:

  • Using your own Computer
  • Using Hosting Service Providers

Hosting a Minecraft server on your own device can be a little complex and resource-consuming and publicly allowing its access can make it vulnerable to DDoS attacks.

Many hosting services can be used to host Minecraft servers. Some paid options are listed below:

Paid hosting services provide better quality of service and are available 24/7 with no downtime. Moreover, they are protected against DDoS attacks.

Free Minecraft server hosting services are listed below:

Keep in mind that free Minecraft server hosting services often have restrictions, such as limited customization options and potential downtime.

Conclusion

Creating and hosting a Minecraft server allows you to shape the gameplay according to your own unique rules. There are various platforms to create and host Minecraft servers. Ubuntu is lightweight and secure, making it one of the best choices for creating a Minecraft server. There are two Minecraft editions Java and Bedrock edition. So, both versions have different methods for server creation and this guide covers both methods comprehensively. When it comes to hosting, it is advised to use Minecraft server hosting services because they are secure, however, if your server is for private use then it is perfect to set it up on your own computer.

Exit mobile version