Simple Debian 11 Minecraft Server – Part 2

Published on December 5, 2021 at 6:45 am by LEW

Minecraft ImageIntroduction

In the last post we initialized our Minecraft server by setting up a base Debian 11 install, along with some additional programs. Today we will continue working on or Minecraft server by creating the minecraft user to manage the game from.

Part of creating the minecraft user is determining where we want to install Minecraft,so we will look at some options in that regard as well.

We will finish this post up by getting the program and running on our server.

Where to Put the Minecraft Server Files

Our next important decision, where do we put our Minecraft files? We do not want to run our Minecraft server from root for security reasons, and we might not want to run it from our normal user account for administrative reasons.

One easy solution is to setup a separate minecraft user with their own home directory, and put all the files in there.

Additionally, we can also assign the minecraft user home directory to a location like /opt or /srv when creating the user. This would have the advantage of easily separating out the high level folder to their own partition, keeping Minecraft separate from the rest of the system.

For this example, for simplicity, we will set the minecraft user home directory to /home/minecraft.

Advanced Install Option: If you are just creating your server, you can consider putting the /opt or /srv folder on its own partition, for an added level of security and control. The actual server setup, other than location and path will be no different.

Create a MineCraft User

We are creating a separate minecraft user with the useradd program. For a complete list of options refer to the man page.

You can also use the higher level adduser command, But I have found this to to be somewhat problematic with the type of user we are creating. use the following command to create the minecraft user.

useradd -m -r -U -s /bin/bash minecraft

Here is a quick breakdown of the command.

Note on more advanced install: if using an alternate directory location, then add the -d option. This is used to specify an alternate path for the home directory. For example; -d /srv/minecraft.

Also by not giving the minecraft user a password, we prevent console login to the minecraft account

Getting Minecraft Server

There are a couple of different ways to install the Minecraft server program. One way is to download it on your regular computer and use scp or a usb device to copy it over. Another way is to download it directly to your server if it has an internet connection. I am covering direct download here.

Regardless of how it gets installed, you need to download the program from the manufacturers site. As of this writing, this link will take you directly to the latest version.

For direct download first su, with the -l option, to the minecraft account (the -l option makes sure the account uses the correct settings). Then from command line you use the wget program, with the download address.

su -l minecraft

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

Complete Minecraft Serve Install

The current Minecraft Server version as of this writing is 1.18. You may want to change the name of the server.jar download to match the version. This will prevent downloading over your current version when another version becomes available, as it will also be called server.jar.

I prefer to rename server.jar to server.A.jar. (A for active). This serves the same purpose as the above, but has the added benefit of not having to change startup scripts (we will get to that a little later).

To finish the install, we need to run the server.A.jar file. Because it is a “.jar” file, it must be run in the java environment we installed earlier. This is done from within the minecraft home directory with the command below.

java -Xms1024M -Xmx2048M -jar server.A.jar nogui

We break down the command as follows.

Agree to EULA

There will be some disk activity after you run the server.A.jar file, before it exits back to the command prompt with a message about agreeing to the EULA (End User License Agreement). If you list the minecraft home directory content, you will see that several folders and files have been created, including eula.text. You need to open this file in your favorite text editor, and enter/set the following. If it is not in the text file, then add it.

eula=true”

The next time you run the server.A.jar, it will create a minecraft world. This may take some time, depending on your hardware. Once it is finished, you will be at a blank line. Type “/stop” to exit the server.

Modifying how the minecraft server operates is out of scope for these posts. For information on running a server from the command line please refer to these posts; Minecraft server Console Basic User Management, and Minecraft Console Server Basic World Management.

Conclusion

In this post we have installed the minecraft server jar file and run it twice. The first time to generate the necessary files including the eula.txt file. The second time to create a minecraft world.

In the next post we will join our server from a minecraft program, and test its functionality. Once satisfied, we will create a startup script to run  minecraft under the screen terminal multiplexer, and finally set the startup script to run at boot time.

Simple Debian 11 Minecraft Server – Part 1

Simple Debian 11 Minecraft Server – Part 2

Simple Debian 11 Minecraft Server – Part 3

David Brand says:

create the password for mcuser before doing su.

passwd mcuser

LEW says:

Thank you for replying. Yes, I agree, as a normal user the minecraft account will need a password to su to. However, you can technically su to the minecraft user from root without a password. If adding a password to the account, then I would want to disable any direct login for security.

Lee Wulff

Add New Comment

Your email address will not be published. Required fields are marked *