Jun 23, 2023 8 min read

How to Create a Minecraft Server on Ubuntu 20.04

Create a Minecraft Server on Ubuntu 20.04 with our step-by-step tutorial. It's a popular video game that lets users create a world of their own.

Create a Minecraft Server on Ubuntu 20.04
Table of Contents

Choose a different version or distribution


Before we get started on the installation process for Minecraft on Ubuntu 20.04, let's briefly understand – What is Minecraft?

Minecraft is an immensely popular sandbox video game that lets players unleash their creativity and explore virtual worlds. Created by Mojang Studios, Minecraft offers endless possibilities, allowing players to build structures, mine resources, and embark on thrilling adventures.

Its pixelated graphics and simple gameplay have captivated millions of players worldwide. Whether you're constructing elaborate castles, surviving against hostile creatures, or collaborating with friends in multiplayer mode, Minecraft offers a captivating and immersive experience that has become a cultural phenomenon.

Discover the limitless potential of Minecraft and let your imagination soar in this extraordinary virtual universe.

In this tutorial, you will create Minecraft Server on Ubuntu 20.04. We will also address few FAQs on how to create Minecraft Server on Ubuntu 20.04.

Advantages of Minecraft Server

  1. Creativity: Minecraft allows players to express their creativity by building and designing unique structures and landscapes.
  2. Exploration: With vast, procedurally generated worlds to discover, players can embark on exciting adventures and uncover hidden treasures.
  3. Multiplayer: Join forces with friends or connect with players worldwide, collaborating on massive construction projects or engaging in thrilling PvP battles.
  4. Educational: Minecraft promotes critical thinking, problem-solving, and resource management skills, making it a valuable educational tool for both children and adults.
  5. Endless Replayability: With its open-ended gameplay and a thriving modding community, Minecraft offers limitless possibilities, ensuring no two experiences are the same.

Prerequisites to Create a Minecraft Server on Ubuntu 20.04

To be able to install the packages, you must be a user with sudo privileges.

The packages required to create the mcrcon tool will be installed by:

sudo apt update
sudo apt install git build-essential

Step 1 – Install the Java Runtime Environment

1) Minecraft requires Java 8 version or above. A graphical user interface is not required for the Minecraft Server. Install the headless JRE version instead, since server applications are better suited to it. It also consumes fewer system resources and has fewer dependencies. Run the following commands to install the headless OpenJRE 8 package:

sudo apt install openjdk-8-jre-headless

2) Print the following to confirm the Java version installation:

java -version

The following output will appear:


openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

Step 2 – Creating the Minecraft User

1) Due to security reasons, Minecraft should never be executed as the root user. To launch the Minecraft server, you must create a new system user and group in the home directory /opt/minecraft.

sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft

Step 3 – Install Minecraft on Ubuntu

1) Begin by switching to the minecraft user.

sudo su - minecraft

2) Use the command below to create three new directories:

mkdir -p ~/{backups,tools,server}
  • Backups directory for saving server backups.
  • The Tools directory contains the mcrcon client and the backup script.
  • Server directory for the main Minecraft server and its data.

Downloading and Compiling

1) To connect to the Minecraft server and run commands, use the RCON protocol. To create the mcrcon binary, you must get the source code from Github.

2) Go to the ~/tools directory and clone the Tiiffi/mcrcon repository from GitHub.

cd ~/tools && git clone https://github.com/Tiiffi/mcrcon.git

3) After the cloning is finished, switch to the repository directory.

cd ~/tools/mcrcon

4) Execute the following command to compile the mcrcon utility:

gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c

Once the compilation is complete, test it.

./mcrcon -h

You should see something like this:


Usage: mcrcon [OPTIONS]... [COMMANDS]...
Sends rcon commands to Minecraft server.

  -h		Print usage
  -H		Server address
  -P		Port (default is 25575)
  -p		Rcon password
  -t		Interactive terminal mode
  -s		Silent mode (do not print received packets)
  -c		Disable colors
  -r		Output raw packets (debugging and custom handling)
  -v		Output version information

Set Server address, port and password using following environment variables:

Command-line options will override environment variables.
Rcon commands with arguments must be enclosed in quotes.

	mcrcon -H my.minecraft.server -p password "say Server is restarting!" save-all stop

mcrcon 0.6.1 (built: May 19 2019 23:39:16)
Report bugs to tiiffi_at_gmail_dot_com or https://github.com/Tiiffi/mcrcon/issues/

Step 4 – Downloading Minecraft Server

1) You can add features to the Minecraft server using mods like Craftbuk-kit or Spigot. It enhances and further personalizes the server settings. You will now install the most recent version of Mojang's official vanilla Minecraft server.

2) Before moving on to the next step, check the Minecraft download page.

3) Next, execute the wget command below. The Minecraft jar file will be downloaded to the ~/server directory:

wget https://launcher.mojang.com/v1/objects/ed76d597a44c5266be2a7fcd77a8270f1f0bc118/server.jar -P ~/server

Step 5 – Next, set up the Minecraft server

1) Start the Minecraft server by navigating to the ~/server directory after the download is finished:

cd ~/server
java -Xmx1024M -Xms512M -jar server.jar nogui

2) The first time you start the server, it does some operations, creates the server.properties and eula.txt files, and then stops.

[23:41:44] [main/ERROR]: Failed to load properties from file: server.properties
[23:41:45] [main/WARN]: Failed to load eula.txt
[23:41:45] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

3) To operate the server, you must accept the terms of the Minecraft EULA. Change eula=false to eula=true by opening the eula.txt file:

nano ~/server/eula.txt
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Dec 19 23:41:45 PDT 2022

4) Finally, save and close the file.

5) Next, you must make changes to the server.properties file. It will set the rcon password and enable the rcon protocol. So use a text editor to open the file.

nano ~/server/server.properties

6) Then, as indicated below, locate the following lines and change their values:

Change the strong password to a more secure one. Make sure your firewall is blocking the rcon port if you do not want people in remote locations to be able to connect to the Minecraft server.

You can even change the default properties of the server. For further information, go to the official server.properties page.

Step 6 – Creating Systemd Unit File

1) You must now create a new Systemd unit file in order to execute Minecraft as a service.

2) Type exit to go back to the sudo user.

3) Next, open a text editor, and then create a file named minecraft.service in /etc/systemd/system/:

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

4) Paste the below configurations now:

Description=Minecraft Server

SuccessExitStatus=0 1
ExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar server.jar nogui
ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H -P 25575 -p strong-password stop


5) You must adjust the Xmx and Xms flags in accordance with your server's resources. The maximum memory allotment for a Java virtual machine is indicated here by the Xmx flag (JVM). Xms, on the other hand, refers to the initial memory allocation pool. Also, ensure that you are using the correct rcon port and password.

6) Next, save and exit the document. Use this command to reload the systemd manager configuration:

sudo systemctl daemon-reload

7) Execute the following command to launch the Minecraft server:

sudo systemctl start minecraft

8) When you launch the service for the first time, it will also create numerous configuration files and directories, including the Minecraft world. By executing the next command, you can determine the status of the service:

sudo systemctl status minecraft

* minecraft.service - Minecraft Server
   Loaded: loaded (/etc/systemd/system/minecraft.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-05-19 23:49:18 PDT; 9min ago
 Main PID: 11262 (java)
    Tasks: 19 (limit: 2319)
   CGroup: /system.slice/minecraft.service
           `-11262 /usr/bin/java -Xmx1024M -Xms512M -jar server.jar nogui

9) Lastly, it allows the Minecraft service to launch automatically when the computer boots:

sudo systemctl enable minecraft

Step 7 – Adjusting the Firewall

If the server is secured by a firewall, and you need to connect to it from outside your local network, you must enable the port 25565.

Run the command below to allow traffic on the default Minecraft port 25565:

sudo ufw allow 25565/tcp

Step 8 – Configuring the Backups

1) You will now create a backup shell script and cronjob. It will back up the Minecraft server automatically.

Change to user minecraft first:

sudo su - minecraft

2) Next, launch a text editor, and make the following file:

nano /opt/minecraft/tools/backup.sh

3) After that, paste the configurations listed below:


function rcon {
  /opt/minecraft/tools/mcrcon/mcrcon -H -P 25575 -p strong-password "$1"

rcon "save-off"
rcon "save-all"
tar -cvpzf /opt/minecraft/backups/server-$(date +%F-%H-%M).tar.gz /opt/minecraft/server
rcon "save-on"

## Delete older backups
find /opt/minecraft/backups/ -type f -mtime +7 -name '*.gz' -delete

4) After that, you must save the file. Run the following chmod command to make the script executable:

chmod +x /opt/minecraft/tools/backup.sh

5) Next, create a cron job. It will automatically run at a set time once every day.

Use the next command to view the crontab file:

crontab -e

6) Now, every day at roughly 21:00, run the backup script. You will insert the following line:

0 21 * * * /opt/minecraft/tools/backup.sh

Step 9 – Accessing the Minecraft Console

1) You must use the mcrcon utility to access the Minecraft Console. Also, you must use the -t switch and mention the host, rcon-port, and rcon-password. Run the following commands to activate the mcrcon terminal mode:

/opt/minecraft/tools/mcrcon/mcrcon -H -P 25575 -p strong-password -t

The output will be as follows:

Logged in. Type "Q" to quit!

2) Furthermore, while accessing the Minecraft Console from a remote location, ensure that the rcon port is not blocked. If you are a regular user, you should create a bash alias rather than connecting to the Minecraft console.

FAQs to Create a Minecraft Server on Ubuntu 20.04

What version of Minecraft server should I use?

It is recommended to use the latest stable version of the Minecraft server available from the official Minecraft website.

How do I download the Minecraft server file?

You can download the Minecraft server file by visiting the official Minecraft website and selecting the "Download" option.

What are the system requirements for a Minecraft server?

The system requirements depend on the number of players, but generally, you'll need a decent CPU, plenty of RAM, and sufficient storage space.

How do I create a new directory for the Minecraft server?

Use the command mkdir followed by the desired directory name to create a new directory for the Minecraft server.

Can I run the Minecraft server in the background?

Yes, you can use tools like screen or tmux to run the server in the background and detach from the session.

How can I manage player permissions on my Minecraft server?

You can use a plugin like "PermissionsEx" or "LuckPerms" to manage player permissions and assign different levels of access and control.


We hope that this comprehensive tutorial made it clear how to set up Minecraft on an Ubuntu 20.04 server. Visit the official Minecraft installation document for additional information on installation.

Please leave a comment below if you have any questions, and we will be glad to address them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.