How To Create A Minecraft Server On Ubuntu 20.04


The Tech Education Fund was the recipient of a donation from Write for DOnations.



Introduction



Minecraft is a popular sandbox video game. It was released in 2009 and allows players the freedom to create, explore, craft, or survive in a 3D-generated block world. It was the second most popular video game in late 2019 This tutorial will show how to create a Minecraft server that you and your friend can use. You will install the required software packages for Minecraft, configure the server, and then deploy it.



Alternately, you can explore DigitalOcean’s One-Click Minecraft: Java Edition Server as another installation path.



This tutorial uses Java Minecraft. This tutorial will not work if your Minecraft version was purchased through the Microsoft App Store. The Microsoft version of Minecraft is also available for most Minecraft versions purchased on gaming consoles like the PlayStation 4, Xbox One or Nintendo Switch. These consoles cannot connect to the server created in this tutorial. The Java version of Minecraft can be downloaded here.



Prerequisites



In order to follow this guide, you’ll need:



– A server with a fresh installation of Ubuntu 20.04, a non-root user with sudo privileges, and SSH enabled. To initialize your server, follow this guide. Minecraft can be resource-intensive, so keep that in mind when selecting your server size. DigitalOcean allows you to resize your Droplet to increase CPUs and RAM.



– A copy of Minecraft Java Edition installed on a local Mac, Windows, or Linux machine.



Step 1 – Install the necessary software packages and configure the firewall



Once you have your server up and running, it’s time to install Java. Java is required to run Minecraft.



Update the package index to the APT Package Manager:



sudo update Next, download the OpenJDK Version 16 of Java. This includes the headless JRE. This is a minimal version of Java that removes the support for GUI applications. This makes it perfect for running Java applications on servers.



sudo apt install openjdk-16-jre-headless You also need to use a software called screen to create detachable server sessions. screen allows you create a terminal session, then detach it from it. The process will continue as normal. This is important because if your server were to be started and then closed your terminal, it would kill the session. Install screen now:



sudo apt install screen


Now that you have the packages installed we need to enable the firewall to allow traffic to come in to our Minecraft server. You allowed traffic only from SSH in the initial server setup. Now you need to allow for traffic to come in via port 25565, which is the default port that Minecraft uses to allow connections. Run the following command to add firewall rules:



sudo ufw allow 25565


Now that you have Java installed and your firewall properly configured, you will download the Minecraft server from the Minecraft website.



Step 2 – Downloading the latest Minecraft Version



Now you need to download the current version of the Minecraft server. You can do this by navigating to Minecraft’s Website and copying the link that says Download minecraft_server.X.X.X.jar, where the X’s are the latest version of the server.



You can now use the copied link and wget to download the server.



wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar


If you intend to upgrade your Minecraft server, or if you want to run different versions of Minecraft, rename the downloaded server.jar to minecraft_server_1.15.2.jar, matching the highlighted version numbers to whatever version you just downloaded:



mv server.jar minecraft_server_1.15.2.jar


You can find older versions archived at mcversions.net if you wish to download Minecraft. This tutorial will only cover the latest version. Now that you have your download let’s start configuring your Minecraft server.



Step 3 – Configuring and Running the Minecraft Server



Now that you have the Minecraft jar downloaded, you are ready to run it.



First, start a screen session by running the screen command:



screen


After you have read the banner, press the SPACE button. This will open a terminal session, just as usual. This session can now be detached, so you can start a command and then leave it running.



Now you can execute your initial configuration. Do not panic if this command throws an error. Minecraft designed its installation so that users must agree to the company’s licensing agreements. You will do this next:



1. java -Xms1024M -Xmx1024M -jar minecraft_server_1.15.2.jar nogui


Before examining this command’s output, let’s take a closer look at all these command-line arguments, which are tuning your server:



– Xms1024M This will allow the server to be started with either 1024MB or 1GB RAM. You can increase this limit if your server needs more RAM. You can choose between M for megabytes or G for gigabytes. For example: Xms2G will start the server with 2 gigabytes of RAM.



– Xmx1024M- This sets the server to only use 1024M in RAM. This limit can be raised if you wish to allow more players or if the server is slow.



– jar This flag specifies which server file to run.



– nogui: This tells a server not to launch any GUI since it is a server.



This command will not normally start your server the first time it is run. Instead, it will produce the following error



These errors were generated by the server failing to find the two required files for execution: the EULA, End User License Agreement, found in eula.txt. and the configuration.properties. The server was unable find these files and created them in your current directory.



First, open eula.txt in nano or your favorite text editor:



nano eula.txt


You will find a link in this file to the Minecraft EULA. Copy the URL.



Open the URL in your web browser and read the agreement. Return to your text editor, and then find the last line in “eula.txt”. This will change eula=false into eula=true. Save and close the file.



Now that you’ve accepted the EULA, it is time to configure the server to your specifications.



In your current working directory, you will also find the newly created server.properties file. This file contains all of the configuration options for your Minecraft server. You can find a complete list on the Official Minecraft Wiki of all server property information. This file can be modified with your preferred settings, before you start your server. This tutorial will discuss the fundamental properties.



nano server.properties


This is how your file will look like:



Let’s take a closer look at some of the most important properties in this list:



– difficulty (default easy) – This sets the difficulty of the game, such as how much damage is dealt and how the elements affect your player. The options are peaceful, easy, normal, and hard.



– Gamemode (default survival) ā€“ This determines the game mode. There are three options: survival; creative; adventure; and spectator.



– level-name (default world) – This sets the name of your server that will appear in the client. You may need to escape characters such as the apostrophe with a backslash.



– motd (default A Minecraft Server) – The message that is displayed in the server list of the Minecraft client.



– pvp (default true) – Enables Player versus Player combat. If true, players can engage in combat with each other and cause damage.



Once you have set the options that you want, save and close the file.



After you have set your settings to true and changed EULA to true, you can now successfully start your server.



Let’s continue the same way as last time and start our server with 1024M of RAM. Let’s give Minecraft access up to 4G of RAM. This number can be adjusted to fit the server’s requirements or server limitations.



1. java -Xms1024M -Xmx4G -jar minecraft_server_1.15.2.jar nogui


Give the initialization time. Soon your new Minecraft server will start producing an output similar to this:



Once the server is up and running, you will see the following output:



You have been dropped into the server administrator panel. Your server is now up and running. Now type help:



Help


This output will be available:



From this terminal you can execute administrator commands and control your Minecraft server. minecraftservers.best Now let’s use screen to keep your new server running, even after you log out. Next, you can connect to Minecraft and start a new Minecraft server.



Step 4 – Keeping the Server Running



Once you have set up your server, you want it running even after you disconnect. Screen can be detached by pressing Ctrl+A + D. You’ll then be back in your original shell.


This command will display all screen sessions.



screen -list This output will contain the ID of your session. You’ll need this ID to resume the session.



To resume your session, pass the -r flag to the screen command and then enter your session ID:



screen -r 266553 You can log out of your server by detaching from the session using Ctrl +A + D, and then log out.



Step 5 – Connecting to the Minecraft Server from the Minecraft Client



Let’s connect to your server now that it is up and running. You can then play!



Launch Minecraft Java Edition. In the menu, select Multiplayer.



Next, add a server to connect. Click on the Add Server button.



The Edit Server Info screen opens. Give your server name and enter your server’s IP address. This is the same IP address you used to connect via SSH.



Once you have entered your server name, IP address, you will be taken back to Multiplayer screen. Your server will now be listed.



From now on, your server will always appear in this list. Select it and click Join Server.



You are now in control of your server and are ready to play.



You now have a Minecraft server running on Ubuntu 20.04 for you and all of your friends to play on! Have fun exploring, crafting and surviving in a 3D world. And remember: watch out for griefers.

Leave a comment

Design a site like this with WordPress.com
Get started