Article

Table of Contents
Theme:
Was this article helpful?

3  out of  4 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Install a Minecraft Server on Ubuntu 20.04

Last Updated: Thu, Feb 11, 2021
Minecraft

Introduction

This article explains the steps to install Minecraft cloud gaming servers on Ubuntu 20.04.

Prerequisites

1. Create a Minecraft User

Create a sudo user named minecraft.

# adduser minecraft
# usermod -aG sudo minecraft

Switch to the new user.

# su - Minecraft

2. Install Java and Screen

Update the package index.

$ sudo apt update

Install Java.

$ sudo apt install openjdk-8-jdk -y

Install Screen. This allows your server to run without leaving your terminal open.

$ sudo apt install screen -y

Confirm the installed packages.

$ sudo java -version

3. Install the Minecraft Server

Create a new server directory for your server files.

$ mkdir minecraft

Move to the directory.

$ cd minecraft

Install wget

$ sudo apt install wget

Navigate to https://www.minecraft.net/en-us/download/server to find the download links for the latest version of Minecraft. Download it with wget. For example, with version 1.16.4`, run:

$ sudo wget https://launcher.mojang.com/v1/objects/35139deedbd5182953cf1caa23835da59ca3d7cd/server.jar

Run the server. The 1024M parameter in -Xms1024M -Xmx1024M configures Java for 1 GB of RAM. Change this to the amount of RAM you want to allocate for Minecraft. The operating system requires available RAM as well, please don't assign all available RAM to Minecraft. For example, if the server has 4 GB RAM, you might consider setting -Xms3072M -Xmx3072M.

$ java -Xmx1024M -Xms1024M -jar server.jar nogui

You should receive an similar output to this.

[main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

To agree to the EULA, edit eula.txt.

$ sudo nano eula.txt

Find the line that says eula=false and change it to eula=true. Save and exit the file.

Create a startup script for your server.

$ nano start.sh

Paste the following into start.sh. Adjust the Xmx and Xms RAM values as needed.

#!/bin/sh
while true
do
java -Xmx1024M -Xms1024M -jar server.jar nogui
echo "restarting in 10"
sleep 10
done

Save and exit the file.

Make start.sh executable.

$ chmod +x start.sh

Create a screen instance for the server.

$ sudo screen -S "Minecraft Server"

Start your server script.

$ ./start.sh

To exit the screen session, press CTRL + A then D. To resume the screen session, run:

$ sudo screen -R

Server Modification Tips

Here are some tips for your Minecraft server:

  • You can use Minecraft commands in the screen session without a leading /. For example op @a will make everybody online a server operator.
  • To modify the general game settings for your Minecraft server, input the command sudo nano server.properties to get access to them.
  • The Minecraft server creates a new directory called world on the first launch for Minecraft modifications, datapacks, and other features.

References

Want to contribute?

You could earn up to $600 by adding new articles