Running and Configure a Minecraft Server with mods on Linux

Henrique Melo
4 min readFeb 16, 2021
Minecraft Image

Like in any game, Minecraft is funnier to play with friends and mods. If you are like me, at some moment, your group of friends wanted to remember old times and replay Minecraft.

I will show you how to install and set up your Minecraft server with some mods so that you can play with your friends.

First, you will need a dedicated machine. You can use a dedicated server, a raspberry pi, or an old desktop.

For this tutorial, I will use Ubuntu 18.04 LTS so, make sure that you are on the same operating system.

I’ve chosen to use a dedicated server for this tutorial, with 4GB of RAM and 2 CPU cores.

Once you have access to your server, you want to check for any updates and keep your system up to date with this command:

sudo apt-get update && sudo apt-get upgrade -y

After that, we will configure the firewall of the server so that your server is protected.

First of all, we need to check if the firewall is active so, we will use this command:

sudo ufw status

If you are using a connection through SSH, we will open the port responsible for the SSH connection, the default port is 22, so it’s the port that I will open along with port 25565.

Port 25565 is the default port where the Minecraft server runs, but you can change it to the port you want. Later on, I will explain how to configure the Minecraft server to run on that port.

We will use these two commands to open the previous ports:

sudo ufw allow 22

sudo ufw allow 25565

With that done, we will enable our firewall with the following command:

sudo ufw enable

Witch our firewall up and running, we can start now installing Java.

For this tutorial, we will install Java 8 using this command:

sudo apt-get install git openjdk-8-jre tar -y

We will use Screen to run our server in a different terminal, so if you don’t have it, you can install it using this command:

sudo apt install screen

Now that we finished the above steps, we can start installing our Minecraft Server.

First, we will create our server folder using the following commands:

cd /opt

sudo mkdir minecraft

cd minecraft

We will use Minecraft Forge to run our server. We will choose a version of Minecraft Forge on their website. I will use version 1.12.2 but, you can use any other version you want.

After choosing the version, you will be using and getting the download link, use this command to download the file:

sudo wget https://link-for-download.com

For the next commands, make sure that you replace the file name with the one you have.

To install Minecraft Forge, we use this command:

sudo java -jar forge-1.12.2–14.23.5.2854-installer.jar — installServer

After that, we will run the server with this command:

cd /opt/minecraft && sudo java -Xms1024M -Xmx3000M -jar /opt/minecraft/forge-1.12.2–14.23.5.2854.jar nogui

You can adjust how much ram the server uses by replacing the values 1024M (Minimum amount) and 3000M (Max amount) for the amount you want.

We will need to agree to the EULA to run the server, so using the following command, we can edit the file and change it from false to true and save it :

sudo nano eula.txt

If you have any mods, you can now copy them to the new folder named mods.

When you are ready, you can use this command to start the Minecraft server:

cd /opt/minecraft && sudo java -Xms1024M -Xmx3000M -jar /opt/minecraft/forge-1.12.2–14.23.5.2854.jar nogui

If you want to configure your server, you can stop it using CTRL + C and using this command to access the server properties and change them:

sudo nano server.properties

These are some of the properties that you can modify:

  • motd -> is the name of the server
  • max-players -> is the max amount of player that can join
  • difficulty -> server difficulty
  • server-port -> the port where the server will run
  • online-mode -> when set to false, it’s possible to join your server using a pirate version of Minecraft

We will create a script so that it’s less complicated to start the server.

Wich the following command, we will create a folder and the script file:

cd /opt && sudo mkdir scripts

cd scripts

sudo nano minecraft.sh

We will copy and paste the following command to the file:

#!/bin/bash

cd /opt/minecraft/ && sudo java -Xms1024M -Xmx3000M -jar /opt/minecraft/forge-1.12.2–14.23.5.2854.jar nogui

Next, we will save it and make it executable:

sudo chmod +x minecraft.sh

Now we can start our server using Screen:

sudo screen -S Minecraft

/opt/scripts/minecraft.sh

Now you have a server to play with all of your friends. You must know how to use Screen and, if needed, how to open ports on your router.

Found this post useful? Kindly tap the 👏 button below! :)

--

--

Henrique Melo

Experienced in development with a passion for tech, I push limits to create groundbreaking software solutions.