Minecraft is still a popular game these days. The simplicity of its graphics had an appeal on gamers of all ages and there are many hundreds of thousands of players worldwide, most of them playing on online servers. But did you know you can create your own Minecraft server using RedHat Enterprise Linux 8? Here is a how to teaching you exactly how to do it.

In this tutorial you will learn:
  • How to install Java
  • How to download and run a Minecraft server
  • How to create a user for the Minecraft server
  • How to open the Minecraft port
A Minecraft server running on RHEL 8
A Minecraft server running on RHEL 8.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RedHat Enterprise Linux 8.0
Software Java
Software Minecraft server JAR file
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Let's install a few things first

The game runs on Java and the Minecraft server also requires Java to run. So we will install Java in RHEL 8 using the Terminal window:


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


$ sudo dnf install java-1.8.0-openjdk-headless.x86_64

It is safer to create a new user just for the Minecraft server. We will call this user mcsvr:

$ sudo adduser mcsvr

Now we need to create a password for this user:

$ sudo passwd mcsvr

When prompted, enter a password for the server user you have just created. If iptables is not yet installed we will install it with

$ sudo dnf install iptables

Log in as the mcsvr user you created above by using



$ su mcsvr

and change the active directory to the mcsvr user's home folder:

$ cd ~

Configuring the Minecraft server

Download the latest Minecraft server JAR file with

$ wget -c https://launcher.mojang.com/v1/objects/f1a0073671057f01aa843443fef34330281333ce/server.jar

and make this file executable with

$ chmod +x server.jar

You can now launch the Minecraft server for the first time using

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

The first time you run the server it will create an eula.txt file that needs to be modified. Edit this file so that the

eula=false

line reads

eula=true

This will let the Minecraft server know that you agree to the End-User License Agreement and you will thus be able to run the server again, this time successfully.

Allowing access to the server

By default, the Minecraft server runs on port 25565. We need to open this port so that you and your friends will be able to connect to the server. Do this with the help of iptables. Become root:

$ su -

and open the 25565 port with

# iptables -I INPUT -p tcp --dport 25565 --syn -j ACCEPT


To be able to keep this port open after a reboot we need to make these changes permanent:

# iptables-save > /etc/sysconfig/iptables

Conclusion

Now that everything is done you can go back to the mcsvr user and launch the Minecraft server again:

# su mcsvr
$ cd ~
$ java -Xmx1024M -Xms1024M -jar server.jar nogui
The nogui parameter tells the server to run in command-line mode. The -Xmx1024M and -Xms1024M parameters tell the server to use 1GB of RAM - the minimum amount recommended by the developers of the game. All you have to do now is to launch the game with your friends and use 127.0.0.1 as a server address to connect to the running Minecraft server you have just created.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions