Minecraft is a kids' sandbox video game where you can build anything that you can imagine. This tutorial will show you how to run your own Minecraft server from your Ubuntu Shell™ from Shells.com.
Update the System
As always, begin by updating your system to the latest version.
sudo apt update -y && sudo apt upgrade -y
Now we must install some of the required dependencies for Minecraft to run.
sudo apt install git build-essential -y
Enter the following command:
sudo apt install openjdk-11-jre-headless -y
Verify the installation is complete and check the version using the command below:
Install the Minecraft Server
First, we must create a separate user for Minecraft to run.
sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft
Now, create a password for your new user:
sudo passwd minecraft
To keep things organized, log in to the account within its own virtual terminal using Screen from the previous steps above. Enter
screen in the terminal to start it.
Open a new terminal window.
Press Ctrl+a and c to open a new terminal window.
In that new terminal window, switch to the Minecraft user that we have just created.
su - minecraft
Now in our Minecraft profile, create the required directories below:
mkdir ~/backups ~/tools ~/server
Next, we need to install mcron, a RCON client that allows you to connect to the Minecraft servers.
Download to the ~/tools directory with the command below:
git clone https://github.com/Tiiffi/mcrcon.git ~/tools/mcrcon
Now, change to the mcrcon directory and build the tool with the command below:
gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c
To verify the installation:
Minecraft Server: Download and Configuration
Download to the ~/server directory with the command below:
wget https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar -P ~/server
Check that you are downloading the most recent version of Minecraft Server or you can and will run into compatibility issues with the clients that attempt to install. Server and client versions must match. To check for the latest version's download link, check the official Minecraft page:
Next, go to the ~/server directory and launch the Minecraft server:
java -Xmx1024M -Xms1024M -jar server.jar nogui
You will receive this error after executing the command:
[07:46:12] [main/ERROR]: Failed to load properties from file: server.properties
[07:46:12] [main/WARN]: Failed to load eula.txt
[07:46:12] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
To fix this, you must agree to the Minecraft EULA. You do this by editing the eula.txt file.
Change the following line from eula=false to eula=true:
Save and close the file. Then, edit the server.properties file and rcon password to EXACTLY the values below.
Edit the following lines in the file:
Save and close, then type exit to log out of Minecraft user.
Create Systemd Service for Minecraft
Now we will create a systemd service file to manage the Minecraft service. You can create it with the following command, but these commands must be run as the system's sudo user and not the Minecraft user.
sudo nano /etc/systemd/system/minecraft.service
Now, copy and paste the following lines to the file:
ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui
ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p your-password stop
Save and close when your file looks like the pic above.
We must restart the systemd daemon for our Shell. To do this without the root password a reboot is required. Restart your Shell™
Log back in as your sudo user, then start and enable the services.
sudo systemctl start minecraft
sudo systemctl enable minecraft
To check and verify the Minecraft service enter:
sudo systemctl status minecraft
To verify that the Minecraft server is running and listening on port 25575, enter the following:
sudo netstat -pnltu | grep 25575
The output should look just like this:
How to Access the Minecraft Console
You can now access the Minecraft with mcrcon utility. Use the following command:
/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p your-password -t
If successful, you should get the following output:
Next, we will log into the game!
How to Access the Server with your Minecraft Client
To download the Minecraft client, you must go to the official Minecraft website and download the installer.
Click 'Get Minecraft' >> Choose 'Computer' >> MINECRAFT: JAVA Edition
You can download and install Minecraft, but you can only use the demo version until you purchase your own copy. Right now the price is $26.95USD.
How To Connect To Your Server
After installing, click PLAY.
Then select Multiplayer, and then click 'Proceed'.
Select Add Server, and then enter the info for your Shell™.
When you have entered the dedicated IP Address to your server, click Done.
As long as you see the status indicator in the upper right corner turn to green bars, you can successfully connect to your server! Double-click on your server or select 'Join Server'.
And we're in! Success! Go, have fun! Play in your own little sandbox!