Skip to content

Instantly share code, notes, and snippets.

@webcrawls
Created August 26, 2020 03:37
Show Gist options
  • Save webcrawls/5a682a1ff13c0164f1637362a4c0127c to your computer and use it in GitHub Desktop.
Save webcrawls/5a682a1ff13c0164f1637362a4c0127c to your computer and use it in GitHub Desktop.
Basic commands to manage a Minecraft server running on Ubuntu 18.04

Introduction

This guide assumes you are using Ubuntu 18.04 Server, you have screen installed, and that your server is already uploaded to the server.

This guide also assumes you have a server start script. You can find one here

Tools

Screen

Screen is a tool used to run processes in the background. It is commonly used to run multiple commands at the same time, but in this case, we'll be using it to run our Minecraft server even if we close our SSH session.

Commands

screen -S minecraft Creates a screen session with the ID minecraft. The name is set via the -S flag. Remember, case-sensitivity is important with command flags.

screen -r minecraft Enters a screen session that is already running. -r means 'restore' or 'reattach'. Assuming you're running a Minecraft server in this screen, you'll be sent to the server's console.

Nano

Nano is a useful text editor, and can be called with nano. Personally, I prefer to use nano for quick and easy stuff, such as copying the start script into a bash file.

Running your server

Assuming we've already entered the server directory with cd, and the start script is already copied, we can start. Make sure the start.sh is executable. To make it executable, use chmod +x start.sh

1. Create your screen session

screen -S minecraft will create a screen session with the default bash command line.

2. Run the server

./start.sh will run the start script. In this scenario, we're using the script I linked in the introduction. This script will start the Minecraft server. Typing stop in the console will end the server process, and the script will give us three seconds to exit the loop. Pressing ctrl+c will stop the script, and thus, exit the loop.

3. Exit the screen session

Pressing ctrl+a+d within a screen session will 'detatch' us from the session. This means that, while we aren't inside the screen session, it is still running and can be reattached to.

4. Reattach to the screen session

screen -r minecraft will reattach us to the session. In the case of our server, this means we're returning to the server's console.

Stuff to remember

Screen

I often find it's easy to create multiple nested screen sessions. In this case, you can type exit to kill the screen session.

You can see what screens are attached and dettached by running screen -r. This will show you all screens, and beside each it will say either (detached) or (attached).

The one that your currently attached to will be suffixed with (attached). Every other screen should say (detached).

File Permissions

By default, created files do not have the ability to be executed. To remedy this, use chmod +x {filename}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment