YouTube Icon

Code Playground.

How to Install Minecraft Server on Ubuntu 18.04


How to Install Minecraft Server on Ubuntu 18.04

Minecraft is one of the most popular games of all time. It is a sandbox online game, which permits its gamers to explore infinite worlds and build the whole lot from simple homes to large skyscrapers.

This tutorial covers the installation and configuration of the Minecraft Server on Ubuntu 18.04. We’ll use Systemd to run the Minecraft server and the mcrcon utility for connecting to the jogging instance. We’ll additionally show you the way to create a cronjob that performs normal server backups.

The identical commands apply for Ubuntu 16.04 and any Ubuntu-primarily based distribution, which include Linux Mint and Elementary OS.

The person you are logged in as must have sudo privileges so that you can install packages.

Install the applications required to construct the mcrcon device:

sudo apt update
sudo apt install git build-essential

Installing Java Runtime Environment
Minecraft requires Java eight or greater. Because the Minecraft Server doesn’t need a graphical user interface, we’ll install the headless model of the JRE. This model is more appropriate for server programs since it has fewer dependencies and uses less system resources.

Install the headless OpenJRE 8 package by means of jogging:

sudo apt install openjdk-8-jre-headless

Verify the set up by means of printing the Java version :

java -version
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)

Creating Minecraft User
For safety functions, Minecraft have to not be run below the root person. We will create a new device consumer and group with home directory /decide/minecraft with the intention to run the Minecraft server:

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

We are not going to set a password for this person. This is right protection practice because this person will no longer be able to login through SSH. To alternate to the minecraft consumer you’ll want to be logged in to the server as root or consumer with sudo privileges.

Installing Minecraft on Ubuntu 
Before beginning with the set up manner, make certain you turn to minecraft consumer.

sudo su - minecraft

Run the subsequent command to create three new directories inside the user home directory:

mkdir -p ~/{backups,tools,server}

The backups listing will keep your server backup. You can later synchronize this listing in your remote backup server.
The equipment listing will save the mcrcon customer and the backup script.
The server directory will contain the real Minecraft server and its statistics.

Downloading and Compiling mcrcon
RCON is a protocol that lets in you to connect with the Minecraft servers and execute commands. Mcron is RCON consumer constructed in C.

We’ll download the supply code from GitHub and build the mcrcon binary.

Start through navigating to the ~/equipment directory and clone the Tiiffi/mcrcon repository from GitHub the use of the subsequent command:

When the cloning is finished, switch to the repository directory:

cd ~/tools && git clone
cd ~/tools/mcrcon

Start the compilation of the mcrcon utility by using typing:

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

Once finished, you may test it via typing:

./mcrcon -h

The output will appearance 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

Server address, port and password can be set 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

Downloading Minecraft Server
There are several Minecraft server mods inclusive of Craftbukkit or Spigot that lets in you to feature capabilities (plugins) in your server and similarly customize and tweak the server settings. In this guide, we are able to deploy the contemporary Mojang’s legitimate vanilla Minecraft server.

The cutting-edge Minecraft server’s Java archive document (JAR) is to be had for down load from the Minecraft download page .
At the time of writing, the state-of-the-art version is 1.14.1. Before continuing with the next step you must check the down load web page for a new edition.
Run the subsequent wget command to down load the Minecraft jar record in the ~/server directory:

wget -P ~/server

Configuring Minecraft Server
Once the down load is completed, navigate to the ~/server listing and begin the Minecraft server:

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

When you begin the server for the first time it executes a few operations and creates the server.Homes and eula.Txt documents and forestalls.

[23:41:44] [main/ERROR]: Failed to load properties from file:
[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.
nano ~/server/eula.txt


#By changing the setting below to TRUE you are indicating your agreement to our EULA (
#Sun May 19 23:41:45 PDT 2019

Close and keep the report.

Next, we need to edit the server.Houses record to enable the rcon protocol and set the rcon password. Open the document the use of your textual content editor:

nano ~/server/

Locate the following strains and replace their values as shown under:



Do no longer overlook to trade the sturdy-password to something greater comfy. If you don’t want to connect to the Minecraft server from far off locations ensure the rcon port is blocked via your firewall.
While right here, you could additionally alter the server’s default residences. For greater information about the viable settings go to the server.Residences web page.

Creating Systemd Unit File

To run Minecraft as a provider we are able to create a new Systemd unit file.
Switch back on your sudo user by way of typing go out.

Open your text editor and create a file named minecraft.Service in /and many others/systemd/gadget/:

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

Paste the following configuration:


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


Modify the Xmx and Xms flags in keeping with your server resources. The Xmx flag defines the maximum reminiscence allocation pool for a Java virtual device (JVM), while Xms defines the preliminary memory allocation pool. Also, make sure which you are the usage of the appropriate rcon port and password.

Save and near the record and reload the systemd manager configuration:

sudo systemctl daemon-reload

Now you could begin the Minecraft server via executing:

sudo systemctl start minecraft

The first time you start the provider it's going to generate numerous configuration files and directories along with the Minecraft international.

Check the carrier repute with the subsequent command:

sudo systemctl reputation 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

Finally, permit the Minecraft carrier to be routinely started out at boot time:

sudo systemctl enable minecraft

Adjusting Firewall
If your server is included with the aid of a firewall and also you need to get admission to Minecraft server from the out of doors of your local community you need to open port 25565.

To permit traffic at the default Minecraft port 25565 type the subsequent command:

sudo ufw allow 25565/tcp

Configuring Backups
In this section, we’ll create a backup shell script and cronjob to robotically backup the Minecraft server.

nano /opt/minecraft/tools/

Start by way of switching to person minecraft:

sudo su - minecraft



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

Save the record and make the script executable through jogging the following chmod command:

chmod +x /opt/minecraft/tools/

Next, create a cron task a good way to run as soon as in a day routinely at a set time.

Open the crontab report through typing:

crontab -e

To run the backup script every day at 23:00 paste the following line:

0 23 * * * /opt/minecraft/tools/

Accessing Minecraft Console
To access the Minecraft Console you can use the mcrcon application. The syntax is as follows, you need to specify the host, rcon port, rcon password and use the -t transfer which allows the mcrcon terminal mode:

/opt/minecraft/tools/mcrcon/mcrcon -H -P 25575 -p strong-password -t
Logged in. Type "Q" to quit!

When gaining access to the Minecraft Console from a far flung vicinity ensure the rcon port is not blocked.

If you're frequently connecting to the Minecraft console, rather than typing this long command you ought to create a bash alias .

You have correctly set up Minecraft server to your Ubuntu 18.04 machine and installation a day by day backup.

If you hit a hassle or have feedback, depart a remark beneath.