How to Install Minecraft Server on Ubuntu 24.04

How to install a Minecraft server (Java Edition) on Ubuntu 24.04 LTS.

Design decisions:

  1. As simple as possible
  2. Use the shell instead of web interface. GUI interfaces seem to create more maintenance and problems than just using a CLI.
  3. Abstract Java and Minecraft server installation and updating with snap.
  4. Use crontab for auto-start (systemd would be the proper way to do this, but this is fast and minimizes complexity).
  5. Self hosted. This gets very intermittent use so I don’t want to pay hundreds of dollars a month for a hosted solution, but when it’s used it needs some CPU. I tried to use usage based cloud instances but found them too sluggish, too expensive, or not near our region (high latency). I found 4 cores and 6GB memory in a Proxmox VM does well.
  6. Keep everything vanilla. No mods means fewer things that can break and not having to do builds to upgrade. If we run into issues I may switch to SpigotMC or such but currently it seems stable.

This setup uses James Tigert’s mc-server-installer snap to install Minecraft server, an expect script (your grandfather’s RPA) to interact with the startup menu, and cron to start the service on system boot.

Install mc-server-installer, and expect

$ sudo su
# snap install mc-server-installer
# apt install expect
# adduser minecraft
# su minecraft
$ cd ~
$ mc-server-installer



ATTENTION: Latest available version: 1.21

Select from the following options: 

1) Download latest (v1.21) server.jar
2) Agree to the EULA
3) Edit the file
4) Run MC server with max 2GB of RAM
5) Run MC server with max 4GB of RAM
6) Run MC server with max 6GB of RAM
7) Run MC server with max 8GB of RAM
8) Run MC server with max 16GB of RAM
9) View README
10) Back up your world
11) Run custom RAM settings
12) Run custom jar file and RAM settings
13) Quit


Choose Option 1 to download the server.jar, re-run and choose 2 to agree to the EULA, re-run and choose 3 to edit (if needed), re-run and choose an option depending on your memory requirements. At this point verify you are able to connect to the Minecraft server. If it’s working CTRL+C to kill it.

If you want to modify the and world files directly, look under /home/minecraft/snap/mc-server-installer/current

Create an Expect Script to Interact with the Menu

$ vim /home/minecraft/

On line 9, I’m sending menu option “6”, but you can change it depending on your memory configuration.

#!/usr/bin/expect -f

set timeout -1
log_file /home/minecraft/minecraft.log
log_user 1
spawn mc-server-installer
expect {
    "Choice: " {
        send "6\r"
    timeout {
        puts "Error: Timeout"
        exit 1
    eof {
        puts "Error: EOF"
        exit 1

Set executable bit…

 $ chmod 755 /home/minecraft/

I suggest running the script once to make sure it works…

$ ./

(CTRL+C to kill it).

Add cron job to autostart Minecraft server on reboot

$ crontab -e

Add the following entry to crontab…

@reboot sleep 10 && export TERM=xterm && /home/minecraft/

Reboot the Ubuntu server.
Tail the log to make sure it starts…

# sudo su minecraft
# tail -F ~/minecraft.log

And now you can connect to the Minecraft server.

After moving all the world and all the files over, the whitelist just worked out of the box on our new Minecraft servers.

Leave a Comment