How to Set Up a Minecraft Server (in Ubuntu 24.04)

https://minecraft.fandom.com/wiki/Tutorials/Setting_up_a_Minecraft_Forge_server

Neoforge works the exact same way

  1. Download forge installer and run java -jar forge-x.xx.x-installer.jar --installServer
  2. Set user_jvm_args.txt:
user_jvm_args.txt
# Xmx and Xms set the maximum and minimum RAM usage, respectively.
# They can take any number, followed by an M or a G.
# M means Megabyte, G means Gigabyte.
# For example, to set the maximum to 3GB: -Xmx3G
# To set the minimum to 2.5GB: -Xms2500M

# A good default for a modded server is 4GB.
# Uncomment the next line to set it.
-Xmx6G
-Xms4G
  1. Modify the run.sh as follows:
#!/usr/bin/env sh
# Forge requires a configured set of both JVM and program arguments.
# Add custom JVM arguments to the user_jvm_args.txt
# Add custom program arguments {such as nogui} to this file in the next line before the "$@" or
#  pass them to this script directly
java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.19.4-45.2.15/unix_args.txt nogui "$@"
  1. Run server with run.sh. It will generate world and fail because eula needs to be acknowledged. Acknowledge the Eula and install mods in the mods folder at root directory (it was generated)
  2. To run detached, install the screen utility with apt install screen. Then, from https://linuxize.com/post/how-to-use-linux-screen/ run screen -dmS [session_name] [command] (from screen --help) to open a new terminal named [session_name] and run [command], (which would be./run.sh). The server should now be in the background
    1. To reattach to the session, run screen -r (also from https://linuxize.com/post/how-to-use-linux-screen/). Pressing Ctrl a and Ctrl d should detach you from the session.
    2. Run screen -ls to identify all screen sessions
    3. Alternatively, you can just run screen without the dmS option, but you'll have some user interaction. Pressing Ctrl a and Ctrl d should detach you from the session.
  3. Optional: Add the screen command to crontab via the following:
@reboot cd /mnt/server && screen -dmS minecraft ./run.sh

Source : https://phoenixnap.com/kb/crontab-reboot


Back to Table of Contents