Getting started with Minecraft on Ubuntu
Putting the penguin and Minecraft together.
Scope
Just like in the title, we’re going to be setting up a Minecraft server. The process is pretty much the same for most of the available Minecraft server versions, like PaperMC, Forge and Spigot.
We will use the screen utility to access our server console.
I’ve written this guide in a way that makes it possible to just copy and paste the code blocks, without actually reading anything. Just look around the codeblocks and change the command if needed.
Tested on Ubuntu 24.04 LTS.
Table of contents
- Things to consider
- Getting started
- Putting the server, into the server…
- First start / installation
- Installing mods (Forge only)
- Installing plugins
- Firewall configuration
- Startup and management
- Java arguments
Things to consider
Infrastructure
Most important things for a Minecraft server are RAM and CPU.
CPU: Minecraft is primarily single-threaded, this means that we should focus on higher clock speeds than the number of cores. If you want to have more servers on a single machine, like TeamSpeak 3 or another game server, multiple cores will be beneficial to distribute the CPU usage.
RAM: The more players and/or plugins/mods you want to have, the more RAM you’re going to need. I can say with confidence that 8 GB should work for around 8 people. Players on their own don’t take a lot of RAM on themselves, but when moving around fast, most of the memory is being used up by chunks. It’s always better to have a bit more RAM than you need to account for those spikes in player activity.
If you’re just starting out your community or need a small server for that few week phase, I highly recommend Hetzner as your server provider due to ease of configuration, good pricing and amount of options. You can use my referral link to get €20 in cloud credits to play around with. This will give you at least a month’s worth of comfortable lag-free gameplay with a group of your friends.
Which server version to use?
To make some things clear: plugins are basically scripts and code that work with the things that are already in the game, while mods introduce new content to the game, like new ores, mobs, etc.
If you want to do vanilla Minecraft with things like custom game modes (SkyBlock) or worlds (plots, more dimensions), you should go for PaperMC. It’s pretty solid, and I can’t say anything bad about its performance. Paper and Spigot do not support mods.
In case you want to load some mods and don’t care about plugins, you’re going to have to go with a version that supports mods, like Forge. In my experience, Forge can be a little messy — and because of it, also pretty overwhelming for beginners — but it’s not that scary or hard to deal with.
Getting started
I’m going to assume you are working as the root user. If you are using a different account instead — congratulations! You should always use your own account instead of root as a security practice — , you may need to add sudo
in front of some commands, to elevate your privileges.
Let’s start by installing Java and the screen package, then — as another security best practice — creating a separate user for the minecraft server. We’re going to be using OpenJDK, and to download it from apt, we have to add their repository to our system’s source list.
add-apt-repository ppa:openjdk-r/ppa && \
apt install openjdk-21-jre-headless screen && useradd -m minecraft
Remember that you can always use
man
to get help about any command. For example:man screen
.
The prompt above will install the package, then — on success (&&
) — create a user named minecraft with its own home directory (-m
).
Now, we can prepare our directory structure. Following the FHS 3.0, we’re going to put our game server in the /srv directory. The most important part is setting the owner (chown
) and permissions (chmod
) of the folder, so that the game server installation process won’t fail.
You can use your own directory name instead of srv1, just remember to use lowercase letters and avoid whitespace.
mkdir /srv/minecraft && \
mkdir /srv/minecraft/srv1 && \
chown minecraft:minecraft /srv/minecraft -Rv && \
chmod u+rwx /srv/minecraft -Rv
The -R
parameter applies changes to files and directories recursively, while the -v
parameter prints out every action that is performed.
Putting the server, into the server…
After we’ve chosen our desired server version, we can upload it into our server using any file manager, like FileZilla and move it into our /srv/minecraft/srv1 directory.
Alternatively, you can download the files directly into your Linux machine using curl. Just go to the directory and use the command.
cd /srv/minecraft/srv1 && \
curl [link to remote .jar file] -o server.jar
Example for PaperMC:
curl https://api.papermc.io/v2/projects/paper/versions/1.21.1/builds/119/downloads/paper-1.21.1-119.jar -o server.jar
Do not forget the
-o server.jar
parameter! This sets the output to file and defines the name that the downloaded file will have on your machine. You may use your own name.You can also use the uppercase
-O
flag instead, to keep the original file name.
Because our server file is new, we have to once again change its owner and permissions:
chown minecraft:minecraft /srv/minecraft/srv1/server.jar -v && \
chmod u+rwx /srv/minecraft/srv1/server.jar -v
The chown
command changes the file owner, while chmod
changes file permissions. We are changing the owner of the file to user minecraft and group minecraft, then adding read, write and execute permissions (+rwx
) for the file owner (u
).
(Optional) Keeping track of your server version
If you’re following along closely and want to properly maintain your server, it’s wise to add the version and type of your server to it’s name, for example: server-1.21.1-paper-119.jar
to help you remember which build specifically you are using.
mv server.jar server-[minecraft version]-[type]-[build].jar
First start / installation
For now, we don’t need any special permissions and can switch to our minecraft user.
su minecraft && cd /srv/minecraft/srv1
Most Minecraft servers are ready out of the box (you just have to accept the EULA and start it again), but Forge has a bit of a different process.
Forge
The jar file we’ve just uploaded to our server is actually not the game server itself, but an installer. The command below will start the installation process of your Forge server, it may take a little while.
java -jar server.jar --installServer
After running it once, we can safely delete it from our machine.
rm server.jar -v
PaperMC, Spigot, Fabric, SpongeVanilla & Vanilla
There’s not much to say here, just start the jar file with Java and let it set up the necessary directories and files.
Remember to not delete your server.jar file! This is your game server!
java -jar server.jar --nogui
Accept the EULA
Open up the eula.txt
file with your text editor of choice. I recommend using nano for it’s ease of use.
nano eula.txt
Then just change the eula=false
to eula=true
and press Ctrl+X
to close, Y
to confirm save and Enter
to confirm the file name (do not change the file name).
Installing mods (Forge only)
Despite what others tend to say, installing mods to your server is pretty straight forward.
In your server installation directory, you will see the new mods directory that was created after you installed or first ran the Minecraft server. That’s where all your mod .jar
files will go to. You can either just drop them there using your preferred FTP/SFTP client, or download the mods directly onto your server.
Let’s switch to that new mods folder.
cd mods
To download your mods directly onto your server, we will once again use the curl
command. We should use the uppercase -O
flag, as we don’t need to alter the file name.
curl -O [link-to-your-mod].jar
Example:
curl -O https://mediafilez.forgecdn.net/files/4847/9/naturalist-forge-4.0.3-1.20.1.jar
The last thing we need to do is to change the owner and permissions of our new mod file. You should do this every time you place or download any new files in your server directory.
chown minecraft:minecraft /srv/minecraft/srv1/mods -R && \
chmod u+rwx /srv/minecraft/srv1/mods -R
And that’s it! If you want to further configure your mods, you should look into their respective documentation, it’s not that hard :)
Installing plugins
The process for installing plugins is pretty much the same as with mods for Forge, but instead of putting them in your mods directory, you place them in your plugins directory.
The only difference is, most plugins will create their own extra subdirectory in plugins to store their configuration after you run the server with them. It’s very easy to configure them while also keeping everything organized.
So, to install plugins, just do everything in the mods section, but replace mods
with plugins
in the commands!
Firewall configuration
It’s a good practice to always lock down your server and protect it from any bad actors.
Use your preferred firewall tool (I recommend ufw) or hosting provider’s panel to set up the following rules:
- SSH (if using remote connection) — 22/tcp
- Minecraft — 25565/udp&tcp
- Optional Minecraft RCON — 25575/tcp
ufw allow 22/tcp && \
ufw allow 25565 && \
ufw allow 25575/tcp
Important: If you are using other services on your machine, make sure to add their respective ports before enabling your firewall! You may loose access to your machine!
Don’t forget to enable your firewall afterward!
ufw enable
Startup and management
As mentioned at the beginning, we will be using the screen utility to comfortably control our server.
Forge
screen -dmS mcsrv /srv/minecraft/srv1/run.sh
PaperMC, Spigot, Fabric, SpongeVanilla & Vanilla
screen -dmS mcsrv java -jar server.jar --nogui
The commands above will start our server.
-dm
flag will start screen in detached mode, this means that it will not show up in our terminal, just start in the background as a new terminal session;-S
flag will set the session name to whatever we put immediately behind it, in this case:mcsrv
.- Everything after our session name will execute on the new terminal, i.e., in the new screen session we just created.
To make things easier, we should set up some options so we can access this session from other users.
screen -S mcsrv -X multiuser on && screen -S mcsrv -X acladd [your username]
To access our screen session that runs our server, we use screen with the -x
flag.
screen -x minecraft/mcsrv
Because this session started our Minecraft server, accessing it will show us our Minecraft server console. From here, we can do anything you would do as if you were directly starting your server, so whitelist players, set time of day, etc.
Java arguments
Forge
You can add your own Java arguments in a special file called user_jvm_args.txt
located in your server’s main directory.
Just open the file with your preferred text editor, paste your arguments at the end and save! Next time you start your server using the run.sh
script that was created on installation, the server will use those arguments.
PaperMC, Spigot, Fabric, SpongeVanilla & Vanilla
In order to use your own Java arguments, you need to modify the command we use to start the server with screen.
screen -dmS mcsrv java -jar server.jar [your parameters here] --nogui
Example:
screen -dmS mcsrv java -jar server.jar -Xms8G -Xmx8G --nogui
And that’s it! Let me know if you have any questions, I’ll try to answer them in a reasonable timeframe.
Good luck on your adventure!