How To Create A Minecraft Server On Ubuntu 20.04

· 7 min read
How To Create A Minecraft Server On Ubuntu 20.04

The creator chosen the Tech Training Fund to receive a donation as a part of the Write for DOnations program.


Introduction


Minecraft is a well-liked sandbox video recreation. Originally released in 2009, it allows players to build, discover, craft, and survive in a block 3D generated world. As of late 2019, it was the second finest-selling video game of all time. In this tutorial, you will create your own Minecraft server so that you just and your folks can play together. Specifically, you will install the required software packages to run Minecraft, configure the server to run, after which deploy the game.


Alternately, you'll be able to discover DigitalOcean’s One-Click Minecraft: Java Edition Server as one other set up path.


This tutorial makes use of the Java version of Minecraft. If you happen to purchased your model of Minecraft by way of the Microsoft App Store, you will be unable to connect with this server. Most variations of Minecraft bought on gaming consoles such because the PlayStation 4, Xbox One, or Nintendo Change are also the Microsoft model of Minecraft. These consoles are also unable to connect to the server constructed on this tutorial. You may receive the Java version of Minecraft here.


Prerequisites


To be able to observe this information, you’ll need:


- A server with a recent installation of Ubuntu 20.04, a non-root consumer with sudo privileges, and SSH enabled. You'll be able to comply with this information to initialize your server and full these steps. Minecraft can be resource-intensive, so keep that in thoughts when selecting your server dimension. If you're using DigitalOcean and want extra sources, you possibly can always resize your Droplet to add extra CPUs and RAM.


- A copy of Minecraft Java Edition put in on a local Mac, Windows, or Linux machine.


Step 1 - Installing the mandatory Software Packages and Configure the Firewall


With your server initialized, your first step is to put in Java; you’ll need it to run Minecraft.


Replace the bundle index for the APT bundle manager:


sudo apt update

Next, install the OpenJDK model sixteen of Java, particularly the headless JRE. This can be a minimal model of Java that removes the support for GUI purposes. This makes it superb for operating Java purposes on a server:


sudo apt set up openjdk-16-jre-headless

You also want to make use of a software called screen to create detachable server sessions. screen permits you to create a terminal session and detach from it, leaving the method started on it operating. That is necessary because should you have been to start out your server after which shut your terminal, this might kill the session and stop your server. Set up display screen now:


sudo apt set up screen

Now that you've got the packages installed we need to allow the firewall to allow visitors to are available to our Minecraft server. Within the preliminary server setup that you simply carried out you solely allowed traffic from SSH. Now you need to permit for traffic to come in by way of port 25565, which is the default port that Minecraft uses to permit connections. Add the necessary firewall rule by operating the next command:


sudo ufw permit 25565

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


Step 2 - Downloading the latest Model of Minecraft


Now it is advisable to download the current model of the Minecraft server. You can do this by navigating to Minecraft’s Webpage and copying the hyperlink that says Download minecraft_server.X.X.X.jar, the place the X’s are the most recent version of the server.


You can now use wget and the copied hyperlink to obtain the server:


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

In the event you intend to improve your Minecraft server, or if you want to run completely different variations of Minecraft, rename the downloaded server.jar to minecraft_server_1.15.2.jar, matching the highlighted version numbers to no matter version you simply downloaded:


mv server.jar minecraft_server_1.15.2.jar

If you wish to obtain an older version of Minecraft, yow will discover them archived at mcversions.internet. But this tutorial will concentrate on the present latest launch. Now that you've got your download let’s begin configuring your Minecraft server.


Step three - Configuring and Running the Minecraft Server


Now that you've got the Minecraft jar downloaded, you might be able to run it.


First, begin a screen session by operating the display screen command:


screen

Once you have learn the banner that has appeared, press the Area bar. display will current you with a terminal session like normal. This session is now detachable, which signifies that you’ll be in a position to begin a command here and depart it working.


You can now perform your initial configuration. Don't be alarmed when this next command throws an error. Minecraft has designed its installation this way so that customers should first consent to the company’s licensing agreement. You'll do that next:


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


Earlier than inspecting this command’s output, let’s take a better look at all these command-line arguments, which are tuning your server:


- Xms1024M - This configures the server to start out running with 1024MB or 1GB of RAM running. You possibly can raise this limit if you need your server to begin with more RAM. Both M for megabytes and G for gigabytes are supported options. For example: Xms2G will start the server with 2 gigabytes of RAM.


- Xmx1024M - This configures the server to make use of, at most, 1024M of RAM. You'll be able to raise this restrict in order for you your server to run at a larger dimension, allow for more gamers, or if you feel that your server is operating slowly.


- jar - This flag specifies which server jar file to run.


- nogui - This tells the server to not launch a GUI since this can be a server, and you don’t have a graphical user interface.


The primary time you run this command, which usually starts your server, it will as a substitute generate the next error:


These errors have been generated as a result of the server could not discover two crucial recordsdata required for execution: the EULA (End User License Settlement), found in eula.txt, and the configuration file server.properties. Luckily, for the reason that server was unable to seek out these recordsdata, it created them in your current working directory.


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


nano eula.txt

Inside this file, you will notice a link to the Minecraft EULA. Copy the URL:


Open the URL in your web browser and browse the agreement. Then return to your textual content editor and discover the final line in eula.txt. Here, change eula=false to eula=true. Now save and close the file.


Now that you’ve accepted the EULA, it's time to configure the server to your specs.


In your current working directory, you will also discover the newly created server.properties file. This file incorporates all of the configuration choices for your Minecraft server. You could find an in depth checklist of all server properties on the Official Minecraft Wiki. You'll modify this file along with your most well-liked settings before beginning your server. This tutorial will cover the elemental properties:


nano server.properties

Your file will appear like this:


Let’s take a more in-depth look at some of a very powerful properties in this checklist:


- problem (default straightforward) - This sets the difficulty of the game, comparable to how a lot damage is dealt and the way the elements have an effect on your participant. The choices are peaceful, straightforward, normal, and onerous.


- gamemode (default survival) - This units the gameplay mode. The choices are survival, artistic,adventure, and spectator.


- degree-identify (default world) - This units the name of your server that will appear in the shopper. Characters such as the apostrophe could should be escaped with a backslash.


- motd (default A Minecraft Server) - The message that's displayed in the server list of the Minecraft consumer.


- pvp (default true) - Allows Participant versus Participant combat. If set to true, gamers will likely be in a position to have interaction in combat and damage one another.


After you have set the options that you want, save and shut the file.


Now that you have changed EULA to true and configured your settings, you possibly can efficiently start your server.


Like last time, let’s begin your server with 1024M of RAM. Only now, let’s also grant Minecraft the flexibility to use up to 4G of RAM if it needs it. Remember, you're welcome to adjust this number to fit your server limitations or person needs:


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


Give the initialization a number of moments. Soon your new Minecraft server will begin producing an output much like this:


As soon as the server is up and working, you will notice the following output:


Your server is now running, and you've got been dropped into the server administrator control panel. Now type help:


assist

An output like this may appear:


From this terminal you can execute administrator commands and management your Minecraft server. Now let’s use display screen to maintain your new server running, even after you log out. Then you can hook up with your Minecraft client and start a new sport.


Step 4 - Preserving the Server Operating


Now that you have your server up, you need it to stay running even after you disconnect from your SSH session. Since you used display screen earlier, you can detach from this session by pressing Ctrl + A + D. Now you’re back in your authentic shell.


Run this command to see your entire display screen periods:


display screen -record

You’ll get an output with the ID of your session, which you’ll must resume that session:


To resume your session, move the -r flag to the display command after which enter your session ID:


display -r 26653

If you find yourself able to log out of your server, remember to detach from the session with Ctrl + A + D and then log out.


Step 5 - Connecting to Your Server from the Minecraft Consumer


Now that your server is up and working, let’s connect to it via the Minecraft shopper. Then you possibly can play!


Launch your copy of Minecraft Java Edition and choose Multiplayer in the menu.


Next, you will want to add a server to connect with, so click on the Add Server button.


In the Edit Server Information screen that reveals up, give your server a reputation and kind within the IP address of your server. This is identical IP address that you simply used to attach by way of SSH.


After you have entered your server identify and IP handle, you’ll be taken again to the Multiplayer screen where your server will now be listed.


From now on, your server will all the time seem on this checklist. Select it and click on Join Server.


You are in your server and ready to play!


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