How To: Minecraft Server on Ubuntu

So I’ve been playing Minecraft on the Xbox360 for some time now and it started getting a bit repetitious and bland. My son got into the PC version and I was sitting with him and his friends for a few sessions and it got my interest. This weekend I decided to set up a server so they can have somewhere to put their creations and not have to worry about being kicked from someone else’s server or have their city griefed (Griefing is the act of irritating and angering people in video games through the use of destruction, construction, or social engineering.) as well, they were talking about starting to make YouTube vids so this will be good for them. I thought this would have been harder that what it turned out to be, but it wasn’t. So for those wanting to do it but are not sure about how go about it or are afraid of getting their hands dirty in Linux, I created this tutorial.

What is Minecraft?

Minecraft is basically and electronic version of Lego but with so much more. The Xbox version is limited but the PC version is just too awesome and huge to put into words in a post as there are so many features and not to mention the mods and customizations that can be made to it. If you are into developing or know how to script you can create your own customization for Minecraft to make your install yours. As always, if you create something awesome, do share with others. At the end of the article I will post links to related sites.

Minecraft is a sandbox indie game originally created by Swedish programmer Markus “Notch” Persson and later developed and published by Mojang. It was publicly released for the PC on May 17, 2009, as a developmental alpha version and, after gradual updates, was published as a full release version on November 18, 2011. A version for Android was released a month earlier on October 7, and an iOS version was released on November 17, 2011. On May 9, 2012, the game was released on Xbox 360 as an Xbox Live Arcade game, co-developed by 4J Studios. All versions of Minecraft receive periodic updates.
– From Wikipedia, the free encyclopedia

Minecraft is basically a sandbox game where players can break and place blocks to build almost infinite creations. Blocks or Cubes are scaled to 1 cubic Meter and represent different materials like dirt, stone, water, lava, trees and various ores. At start, players spawn with nothing but their two hands and an open world to explore; worlds are divided into biomes ranging from deserts to snowfields. The game has a day-night system as well as a varied weather cycles depending on what biome you are in; like snowfall if you are in a snow biome or rain if you are in another biome.

As the game progresses, players will meet non playable characters knows as mobs. They include non-hostile mobs such as chickens, cows and pigs that can be killed for food, leather or wool and these may change. In the night-time and in dark areas, hostile mobs are set loose, they include giant spiders, skeletons, zombies and creepers. Skeletons come armed with bow and arrows and creepers are equipped with an explosive charge that go off if they get close to you, they make no noise except for the hiss right before they explode. There are other mobs in the game but we won’t go into them all as each version of the game and the platform you play them on present different features and it is too much for this post. Depending on what version you are playing you may have different mobs as well like wolves (non-hostile mobs like wolves will attack if you hit one, then all hell breaks loose; especially if they are in a pack when you do).

Minecraft allows for some sick in-game creations with just the blocks you find in game, even if you have no added mods; for example, with redstone you can create electrical circuits to build primitive mechanics, electrical circuits and logic gates. For example, you can build automatic doors, cannons, timers and more.

There are numerous expansions that you can add to the game, like mod packs, texture packs, resource packs and custom maps. Mods allows one to add features to the game like elements from Portal and The Hunger Games. The Modding community is HUGE, but keep in mind that mods are developed for specific Minecraft Versions, so be careful when you are downloading.

Update: Minecraft has since been bought by Microsoft as of the Sept 2014 for $2.5 Billion Dollars. Read the release here.

Ok, now back to the reason you came here in the first place…

How to setup your own server in Ubuntu.

While I set mine up using Ubuntu 12.04, you can choose to use other Linux variants and switch the commands to suite your OS of choice. The reason I used Ubuntu 12.04 is that it is an LTS (Long Term Support) version and will receive support for 5 years which gives me to April of 2017 until I have to upgrade the OS and I prefer to keep with a stable system. For those that don’t know, Ubuntu releases LTS and non LTS versions of their OS; their naming convention rolls with their release schedule, April and October of every year which gives us a 6 month cycle. 🙂 I will be upgrading sooner or later but I prefer to let the kinks be ironed out before I move on, I’m not a bleeding edge person in this respect. Below is a list of their last few releases that are still alive.

  • Ubuntu 14.04 LTS (Trusty Tahr) EOL: April 2019
  • Ubuntu 16.04 LTS (Xenial Xerus) EOL: April 2021

Tip: You will want to pick the most recent LTS version, 16.04.

First things First

I am assuming that you have already installed your Ubuntu OS; if not, go do that before moving ahead. If you are not sure how to do so, I recommend a quick Google search. You WILL want to select the OpenSSH Server option at the Software Selection screen. I am also assuming that you have some basic knowledge of Ubuntu and the Command Line. The tutorial will be broken up into sections and will cover most things that are needed for running Minecraft as well as securing your server.

Required Packages

These packages are needed before we can proceed any further as well as updating your system before we proceed any further. Make sure you have the right apt setup, see here.

Updating and Upgrading

sudo apt-get update && sudo apt-get upgrade
sudo apt-get update && sudo apt-get dist-upgrade

Open-SSH / VIM

SSH allows you to connect to your server from another computer for administration, maintenance or troubleshooting. If you did not select this during setup, here is how to install it. Vim will be used to edit files, you can use a different editor if you have a favorite like nano.

sudo apt-get install openssh-server vim

UFW – Uncomplicated Fire Wall

UFW is installed by default on most Linux systems, but is not enabled. This means your server is wide open to the entire world. Let’s enable the firewall but first we must add a rule to allow SSH or you will not be able to connect once the firewalls is enabled.

sudo ufw allow 22

Once that rule has been added then we can enable the firewall:

sudo ufw enable

Now we need to enable the other ports we are going to be using. Minecraft runs on a default port of 25565. Run the following command to add the port.

sudo ufw allow 25565

Check the Firewall status to make sure all is setup right:

sudo ufw status

You should see the following:

Status: active
 To                         Action      From
 --                         ------      ----
 22                         ALLOW       Anywhere
 25565                      ALLOW       Anywhere
 22                         ALLOW       Anywhere (v6)
 25565                      ALLOW       Anywhere (v6)


This is a neat little package that keeps track of how many times someone has tried to login to your server (not your MC server, your actual Linux server), and then bans their IP address for a set period of time when someone tries to login via SSH.

Run the command and tell it Yes when it asks if you want to install:

sudo apt-get install fail2ban

The default install on this will probably be fine for you, but you can look at the specific settings in /etc/fail2ban/jail.conf, I use vi to edit.

sudo vi /etc/fail2ban/jail.conf

The Default section contains the default ban length and max retries for all services. You can also set your own IP address to be ignored if you want. The ban time is in seconds, I suggest setting that to a minimum of 24 hours to prevent script kiddies from trying to brute force your machine all day long.

# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip =
bantime  = 86400
maxretry = 3

The SSH section has a different number set for max retry that overrides the default settings. You can change this or leave it as you see fit.

enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 6

Optimize fail2ban

sudo vi /etc/default/fail2ban

Add the following line:

ulimit -s 256

Restart fail2ban

sudo /etc/init.d/fail2ban stop
sudo /etc/init.d/fail2ban start


This is an awesome tool to keep track of CPU and MEM usage, we use it with Shift+M to list usage by memory (highest at the top). To use it simply type htop on the command line then once it’s started use the Shift+M key combination to sort by memory usage.

sudo apt-get install htop


Important: Java is NOT optional, without this Minecraft will NOT run.

Add the PPA:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java

To install java8 run the following:

sudo apt-get update && sudo apt-get install oracle-java8-installer

To install java9 run the following:

sudo apt-get update && sudo apt-get install oracle-java9-installer

To check the Java version after installing the package, run command:

javac -version

Set a static IP

A static IP is used to ensure that your server keeps the same IP all the time and you don’t have to keep going back and looking for an IP. Each Gateway/Router/DHCP-DNS setup is different so you’ll have to figure out how to assign a static address for your setup. Here we will go over setting it on your Ubuntu server. For this example, we’ll be assuming that was the IP you assigned to the MAC Address for your server, the interface name may not be eth0 so check the name by running the following:

ifconfig -a

Your output should look like this:

eth0      Link encap:Ethernet  HWaddr 00:40:F4:1E:BD:2A  
          inet addr:  Bcast:  Mask:
          RX packets:2428371 errors:24 dropped:0 overruns:0 frame:0
          TX packets:2489772 errors:0 dropped:0 overruns:0 carrier:0
          collisions:3497 txqueuelen:100 
          Interrupt:11 Base address:0x1e00

Edit your interfaces file:

sudo vi /etc/network/interfaces

Your file should look like this after you assign the IP:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

Restart the networking service

sudo service networking restart

Users, Folders and Rights

For security reasons we do NOT want to run Minecraft as root so we will create a minecraft user for this purpose as well as create admin accounts that can edit files and configs for the Minecraft server. Make sure you are using secure passwords, read our article on that here.

Create the minecraft user:

sudo adduser minecraft

Create additional users and add them to the minecraft group as needed.

sudo adduser username
sudo usermod -a -G minecraft username

The groups command will check the groups a user belongs to so you can make sure they are in the minecraft group.

groups username

Where to put the files

You can put the files anywhere you’d like but we prefer to create a root directory to keep everything centralized. We’ll create all the directories first and then assign rights and run modes after.

cd /
sudo mkdir minecraft

Next, create backup directories, we all know how important backups are right?

sudo mkdir minecraft/backups

Assign ownership of the minecraft directory tree to the minecraft user and group as well as set proper run mode.

cd /
sudo chown -R minecraft:minecraft minecraft
sudo chmod -R 775 minecraft

Getting the files and performing first run

Before we do anything else we need to grab the server file and perform a first run to get things setup.

Make sure you are in the minecraft directory before proceeding:

cd /minecraft

Become the minecraft user

su - minecraft

To get the server file go here and download the latest server file, as of this writing it is minecraft_server.1.8.7.jar. I use wget for my files so copy the URL to the latest download then run this, remember to change the url to the one you copied:


Rename the downloaded file

sudo mv minecraft_server.1.8.7.jar minecraft_server.jar

Test it out

The following command will start the server, run it with no gui and assign 1GB of ram to the server. Make sure you use an appropriate number depending how much ram your system actually has, this is set in MB so 1GB would be 1024, 2GB would be 2048 and so on.

Get back into the minecraft directory

cd /minecraft

Start minecraft

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

During the run you should see a console that will show you the progress of the setup. Once the run is finished you should be able to connect and play.

Once verified, type stop in the console to stop the server so we can proceed.

Editing settings

Enable the whitelist so that nobody can connect while you are working on your server.

  • Set yourself as an op in ops.txt
  • Set your IP address
  • Set any other options you want on your world, such as enabling PvP or Monsters or whatever.

Here is a copy of my file. The lines in orange are ones that you will need to modify. The IP address will be the one you set as static above, in this example.

As per Minecraft, here are the options for op-permission-level:

  1. Ops can bypass spawn protection.
  2. Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, and /tp, and can edit command blocks.
  3. Ops can use /ban, /deop, /kick, and /op.
  4. Ops can use /stop.
#Minecraft server properties
level-seed=whatever seed you want
level-name=My World
motd=Welcome to My World ツ

Important: The server-ip address will be the address of the server and is for local connection only. For connecting from outside your local network you will need to setup port forwarding and maybe Dynamic DNS settings. These are way too involved to cover here so as usual, Google is your friend.

Enabling whitelisting will create a setup where no one will be able to connect unless they are whitelisted.

I suggest changing the view-distance to 7 to reduce possible lag. This setting handles the way the game loads chunks.

Making it easy

Make sure you are in the minecraft directory still:


which should give you an output like this:


Instead of having to run the long command every time we want to start the server, we’ll create an executable that we can run to do it. Create a new file called and edit it, I use vim but you can do this in your favorite editor as well.


Press i to enter interactive/edit mode and paste in the following:

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

# Log all reboot startups to keep track
exec echo Minecraft server was started/re-started on `date` >> /var/log/minecraft.log

Save and quit:
:wq and press Enter

Make the new file executable by running the following command:

chmod +x

To start the server now all you have to do is run the following command as the minecraft user:


Modded Runs

Here are links to some of the Mod Packs available online.


Screen is a console application that allows you to use multiple terminal sessions within one window. One of the advantages of screen that is you can detach it. Then, you can restore it without losing anything you have done on the screen. There are many situations where creating several terminal windows is not possible or ideal. This will be beneficial if you want to run your server on a cloud or a VM (Virtual Machine) session, as Darkside mentioned in the comments.

Installing Screen

sudo apt-get update && sudo apt-get install screen

Using Screen

To start a new screen session, we simply type the screen command.


Accept the License by pressing Enter as instructed.

Once done you will be dropped back to a normal looking shell. What? Did I mess something up you ask? No, no you did not. To verify that you are on track, issue Ctrl+a the press v, which should respond with the Screen version:

screen 4.01.devel (GNU) 2-May-06

Every keyboard shortcut for screen is prefaced with Ctrl-a (hold the control key while pressing the a key). That sequence of keystrokes tells screen that it needs to pay attention to the next keys we press.

To get a full list of options press Ctrl+a the press v, which will print out the following list:

Screen key bindings, page 1 of 1.

                          Command key:  ^A   Literal ^A:  a

    break       ^B b           license     ,              removebuf   =         
    clear       C              lockscreen  ^X x           reset       Z         
    colon       :              log         H              screen      ^C c      
    copy        ^[ [           login       L              select      '         
    detach      ^D d           meta        a              silence     _         
    digraph     ^V             monitor     M              split       S         
    displays    *              next        ^@ ^N sp n     suspend     ^Z z      
    dumptermcap .              number      N              time        ^T t      
    fit         F              only        Q              title       A         
    flow        ^F f           other       ^A             vbell       ^G        
    focus       ^I             pow_break   B              version     v         
    hardcopy    h              pow_detach  D              width       W         
    help        ?              prev        ^H ^P p ^?     windows     ^W w      
    history     { }            quit                      wrap        ^R r      
    info        i              readbuf              
    kill        K k            redisplay   ^L l           xoff        ^S s      
    lastmsg     ^M m           remove      X              xon         ^Q q

^]   paste .
"    windowlist -b
-    select -
0    select 0
1    select 1
2    select 2
3    select 3
4    select 4
5    select 5
6    select 6
7    select 7
8    select 8
9    select 9
I    login on
O    login off
]    paste .
|    split -v
:kB: focus prev

Let’s test it out shall we?

Let’s say we want to run our Minecraft session but continue to work on the server, let’s say yu want to download a pack of some sort and it will take some time. Start screen:


You start your minecraft session:

cd /minecraft

Now detach from that screen so you can do your other work by issuing Ctrl+a the press d. You should now see a default shell. To re-connect to your sessions, run the following command:

screen -r

Note: When you have more than 1 screen session, you need to type the screen session ID.

To see how many screen are available, issue the following command

screen -ls

Which will output something like this:

There is a screen on:
        17448.pts-0.minecraft   (01/27/2015 09:48:30 PM)        (Attached)

To connect to your seesion again you will need the session id, which in our example is 17448.pts-0. To connect to that session run the following command:

screen -r 17448

Moving about in screen

When you do nested screen, you can switch between screen using command Ctrl-A the press n. It will be move to the next screen. When you need to go to the previous screen, just press Ctrl-A the press p.

Leaving Screen

There are two ways to end your screen sessions. First, is Ctrl-A the press d to detach the screen. Second, we can use the exit command to terminating screen. You also can use Ctrl-A the press K to kill the screen.

Execute Cron Job After System Reboot

crontab is the program used to install, deinstall or list the tables used to drive the cron daemon in Vixie Cron.

Become the minecraft user:

sudo -s
su - minecraft

Start the cron editor as the minecraft user:

crontab -e

You can also edit as the minecraft user while you are still root (sudo -s)

crontab -e -u minecraft

In the editor, paste the following line:

@reboot /minecraft/

Run the following command to finish:

update-rc.d cron defaults

Coming soon:

  • How to setup and use screen to keep your ssh connections to the server alive
  • Setup the server to be ran at boot time, in case of a power failure or needed reboot – (working on this one, will update over the weekend)

That’s it for now.. I’ll keep adding to this as I keep playing with my server. Please let me know if I missed anything and share do your tips, I would love to learn some tricks from you.


83 thoughts on “How To: Minecraft Server on Ubuntu”

  1. you need to add setup of screen because many will be running on a remote VM server will need to be able to close the terminal window without the Minecraft server closing.


    1. Thanks for pointing that out Darkside. I will be adding that section, as well as setting up a “run at boot time”, in case of a power outage or if a server restart is ever needed.


  2. Hello when I try to do the #!/bin/bash
    java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

    It wont let me access the jarfile it says.

    What should i do?


  3. Thank you so much! This worked perfectly with one exception. I needed to run
    apt-get install software-properties-common
    before I could do the
    add-apt-repository ppa:webupd8team/java

    You wouldn’t happen to have a tutorial on setting up a MineCraft forge server, would you?


    1. Not for Forge Jason. I will take some time to review and work on getting one together. It’s something I’ve been meaning to do for a while but never really had the time to dedicate to it as I’m going back to school.


  4. java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui says I need to agree to the eula. So I did, and it’s still giving me the same issue. Suggestions?


  5. lost some ware between
    sudo adduser
    sudo usermod -a -G minecraft


    cd /
    sudo mkdir minecraft

    i get nothing when i type cd /

    what do i do?


    1. never mined but still suck on the java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui as it says it is unable to access jarfile minecraft_server.jar


      1. goodgod101, thanks for the feedback. I am going over the step and will update the article. I think the problem is that I had the permissions set before getting the files setup… Can you run the following, try again and let me know how it works:

        cd /
        sudo chown -R minecraft minecraft
        sudo chmod -R 775 minecraft


      2. Hi, I have the same problem. when I add the 3 commands you tell to do, this is the response : minecraft is not in the sudoers file. Could you please help me ?


        1. Thanks for pointing this out Stexx. While revamping the process I moved the commands around by mistake…

          You should run these before becoming the minecraft user:

          cd /
          sudo chown -R minecraft minecraft
          sudo chmod -R 775 minecraft

          I have updated the document to reflect this.


      3. That’s working !! but now there is this error :

        [23:22:48] [Server thread/INFO]: Starting minecraft server version 1.8.1
        [23:22:48] [Server thread/INFO]: Loading properties
        [23:22:48] [Server thread/INFO]: Default game type: SURVIVAL
        [23:22:48] [Server thread/INFO]: Generating keypair
        [23:22:48] [Server thread/INFO]: Starting Minecraft server on
        [23:22:48] [Server thread/INFO]: Using epoll channel type
        [23:22:49] [Server thread/WARN]: **** FAILED TO BIND TO PORT!
        [23:22:49] [Server thread/WARN]: The exception was: Error during bind(…): Ne peut attribuer l’adresse demandée
        [23:22:49] [Server thread/WARN]: Perhaps a server is already running on that port?
        [23:22:49] [Server thread/INFO]: Stopping server
        [23:22:49] [Server Shutdown Thread/INFO]: Stopping server

        Do you konw why ?


        1. Hi Stexx,

          Can you post the exact command you are running and then run the following commands and post the output?

          This will tell you if the server is running:
          ps aux | grep minecraft

          And should return something like this:
          minecraft 16717 0.0 0.0 71296 1748 ? S 22:56 0:00 minecraft

          If you do get back something, run the following to stop it, remember to change the number as it appears in your output:
          sudo kill 16717

          Try to start the server again.


  6. Hey computero! This was very helpful, although I too had a lot of trouble setting up the minecraft user and groups. I have an issue when I try starting the server while logged in as the minecraft user that after some time I can no longer execute commands in the minecraft server screen session. Is this a screen issue? Or does this have something to do with the user’s privileges? Basically the server is still running, but entering commands in the screen terminal produces no outputs. Any ideas?


    1. Eric,
      Sorry you are experiencing issues. I’m not sure exactly what’s causing the issues with not being able to enter commands. As a side not, you don’t have to use screen if you have physical access to the server and can connect a keyboard to it.

      When it happens, start a new connection to the server and check resources by typing free -m, this will tell you memory usage on your server, it will output something like this:

      total used free shared buffers cached
      Mem: 7839 5197 2642 0 114 1588
      -/+ buffers/cache: 3495 4344
      Swap: 15257 589 14668

      As for setting up the user, what issues specifically were you having?


  7. Are there plans to complete the “Setup the server to be ran at boot time, in case of a power failure or needed reboot” tutorial, I am having a hard time finding a quality walkthrough.


    1. Thanks for your comment Justin.
      Yes, I am still going to get that done.. I’ve been swamped at work and haven’t had time to get that done.. I will work on it this weekend.. Stay tuned.


      1. Hi Justin,

        Just a quick not to let you know that I updated the post with the “Setup server to be ran at boot time.” section. Let me know how it works for you.



  8. I’m seeing screen all around… but screen is much more powerfull… do just this:

    screen -S minecraft -d -m java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
    @reboot /home/minecraft/

    So after reboot our after running by command the screen will start in background and more accessible.

    Try it!


  9. Hello, thanks for this info, this works great also for server version 1.8.8, the server was setup with no problems at all thanks to this tutorial.

    Ps. while im already typing, I can also ask a (very low prio) question:
    I set the .sh script to run with option -d64 for 64bit, like:

    java -Xmx2048M -Xms2048M -jar minecraft_server.1.8.8.jar -d64 nogui

    However, does anyone know how I can know if it really runs in 64bit mode or not?
    (server starts and all, but I dont see anywhere whether it runs in 32bit or 64bit mode)



    1. Hi ks,
      Glad to know this worked for you.

      As for your question, I think it’s actually -J-d64 .. Let me look into it and get back to you with a definitive answer. I will update the article as well.


  10. Hello c0mputer0,

    If been following your tutorial, but I keep having an issue when trying to rename or start the jar. I get the following message.
    “Minecraft is not in the sudoers file.”

    Any ideas on what I have done wrong?


    1. Hi Qazt, sorry to hear you’re having issues.

      Can you let me know what the exact commands are that you are running when you get the error?

      Do the following to check permissions as they should be from following the tutorial:

      cd /minecraft
      ls -l

      You should run these before becoming the minecraft user:

      cd /
      sudo chown -R minecraft minecraft
      sudo chmod -R 775 minecraft

      The first sudo command grants ownership to all files to the minecraft user and the second ensures that the minecraft user can execute all files in the minecraft directory.

      If you are having issues you can do the following:

      become root (not as the minecraft user):

      su -
      sudo -i

      Change to your root directory and rerun the ownership commands again:

      cd /
      sudo chown -R minecraft minecraft
      sudo chmod -R 775 minecraft

      Let me know if this helps.


  11. I still seem to get the error when I type “sudo mv Minecraft_server.1.8.8.jar Minecraft_server.jar”
    This is followed by “[sudo] password for Minecraft:”

    Once I put the password in, I am greeted with “Minecraft is not in the sudoers file. This incident will be reported”

    When I did do the command as root “root@myserver:/#” I typed in “sudo chown -R Minecraft Minecraft” I am Asked for a password, no text follows. Then when I type in “sudo chmod -R 775 Minecraft” there is no request for password or text to confirm that it was completed.

    I am running all this on Ubuntu 14.04.3 LTS (server with nogui )


    1. Let’s try this… Log completely out of the server then log back in with the user account you created when you built the server. Before becoming the minecraft user, do the following:

      Become root:
      sudo -i

      Properly assign ownership and execution rights:
      cd /
      sudo chown -R minecraft minecraft
      sudo chmod -R 775 minecraft

      Now become the minecraft user:
      su - minecraft

      Go to the minecraft directory and run the command again:
      sudo mv minecraft_server.1.8.7.jar minecraft_server.jar

      Also, can you run the following and then paste the results:

      ls -l /minecraft <- if you put the files somewhere else, change /minecraft to wherever you put them.

      You should see output like:

      drwx------+ 4 username username 136 Aug 3 08:49 filename


  12. The following is what i haved typed, and any responses.

    I am logged in as user that was created at os install.

    “User@myserver:~$Sudo -I
    [Sudo] password for user
    Root@myserver:~#cd /
    Root@myserver:~#Sudo chown -R Minecraft Minecraft
    Root@myserver:~#Sudo chmod -R 775 Minecraft
    Root@myserver:~#Su – Minecraft

    Minecraft@myserver:~$ sudo mv Minecraft_server.1.8.8.jar Minecraft_server.jar
    [Sudo] password for Minecraft
    Minecraft is not in sudoers file.
    Minecraft@myserver:/$ Ls -I /Minecraft
    3008770 backups 3008771 Minecraft_server.1.8.8.jar”


  13. It worked but I’m continually having new issues. Including when I run the .jar I get a warning that “you need to agree to the eula in order to run the server. Go to eula.txt for more info.

    I assume that this would be in the Minecraft directory? And opened with mv elua.txt?


    1. Sounds like you need to go back and redo the setup of permissions for the minecraft group and user, and make sure the minecraft folder is setup correctly.


  14. I attempted to redo the usermod command. It comes up with a list of options after putting in the password . the -a is not in the list but the -G is. Typo?


    1. Qazt, just an FYI; you only need to run the usermod command if you add extra users to the server. If you will only be using the minecraft user you don’t need it. Either way, thanks for mentioning this because it pointed out an error I had in the command.


  15. Peeps, sorry about this. I found an issue in the tutorial and it has been updated. I did not have the complete command to add extra users to the minecraft group, the correct command should be:

    sudo usermod -a -G minecraft username


  16. Stexx and others:
    If you see the errors:

    It is because you entered a “server-ip=” address in the file.
    Just put the line back to “server-ip=” and save the file. It will work.


  17. The brackets above were supposed to contain this:
    [23:22:49] [Server thread/WARN]: **** FAILED TO BIND TO PORT!

    If you see that error, remove the IP addess from the file.


  18. Good day,

    Thank you for the wonderful, thorough walk-through.
    I was able to get a server running on Ubuntu, and most things seem fine. However, every once in a while the server crashes. I am wondering if you have any insight into why this is happening.
    Here is the crash log:

    Would it be that I need to update the java version that I am using to run the server? Currently it is java 1.7. Which version do you recommend?

    Thank you!


    1. You should be using 8..

      sudo apt-get install python-software-properties
      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update && sudo apt-get install oracle-java8-installer


  19. Your guide is quite helpful. Everything seems fine except when I start the server I have to use sudo. Otherwise, it just sits in an infinite loop generating properties files.

    I’m sure I’m not doing something correctly, but can’t for the life of me figure it out. I’d like to get this sorted out so that I can properly create the startup script. Any and all help is appreciated.



    1. Thanks Twopeas. Can you run this command and let me know the output:

      ls -lah /minecraft

      You should get output that looks something like this:

      drwxr-xr-x 4 root root 4.0K Dec 31 12:12 ..

      If you set things in a different place, change /minecraft for your location. Verify that the ownership of the directory and files are set to be the user you created in the beginning.


    2. Also, make sure the user is set in the minecraft group (change username to the user you setup):

      groups username

      If the user is not in the group, run this command and change username to the correct username you created:

      sudo usermod -a -G minecraft username


      1. Here is the output:

        total 8.0M
        drwxrwxr-x 6 minecraft root 4.0K Dec 31 20:11 .
        drwxr-xr-x 25 root root 4.0K Dec 31 19:16 ..
        drwxrwxr-x 2 minecraft root 4.0K Dec 31 19:17 backups
        -rwxrwxr-x 1 minecraft root 2 Dec 31 20:58 banned-ips.json
        -rwxrwxr-x 1 minecraft root 2 Dec 31 20:58 banned-players.json
        -rwxrwxr-x 1 minecraft root 180 Dec 31 19:49 eula.txt
        drwxrwxr-x 2 minecraft root 4.0K Dec 31 20:58 logs
        -rwxrwxr-x 1 minecraft root 8.0M Dec 9 07:49 minecraft_server.jar
        -rwxrwxr-x 1 minecraft root 2 Dec 31 20:58 ops.json
        -rwxrwxr-x 1 minecraft root 850 Dec 31 21:06
        -rwxrwxr-x 1 minecraft root 69 Dec 31 20:11
        drwxrwxr-x 8 minecraft root 4.0K Dec 31 21:16 Tom’s Minecraft Server
        -rwxrwxr-x 1 minecraft root 328 Dec 31 21:00 usercache.json
        -rwxrwxr-x 1 minecraft root 2 Dec 31 19:50 whitelist.json
        drwxrwxr-x 7 minecraft root 4.0K Dec 31 19:50 world

        I have two users that I am using: my normal user and the new minecraft user. Both are in the minecraft group.

        Also, thank you very much for the quick response! It is new years ever you know.


      1. I was able to figure it out… So I didn’t realize it at first, but when I tired su – minecraft, I was getting a message the home directory didn’t exist and it never actually switched users. Long story short, there was already a user named minecraft when I tried doing adduser and I completely missed the message.

        You’re guide is great. It was my rushing that caused this.

        However, currently I am fighting with getting the cron job working.


      2. I’ve restarted the server twice, but nothing.

        I tried creating it under the minecraft user and then as root. I received the following after the udpdate:

        root@linux-server:~# update-rc.d cron defaults
        update-rc.d: warning: /etc/init.d/cron missing LSB information
        update-rc.d: see
        System start/stop links for /etc/init.d/cron already exist.

        should I be saving this under a different file name? or in init.d?

        I just left it with it’s defaults which is in /tmp/crontab.LYadrC/crontab


      3. Here are the results of crontab -l

        minecraft@linux-server:~$ crontab -l
        # Edit this file to introduce tasks to be run by cron.
        # Each task to run has to be defined through a single line
        # indicating with different fields when the task will be run
        # and what command to run for the task
        # To define the time you can provide concrete values for
        # minute (m), hour (h), day of month (dom), month (mon),
        # and day of week (dow) or use ‘*’ in these fields (for ‘any’).#
        # Notice that tasks will be started based on the cron’s system
        # daemon’s notion of time and timezones.
        # Output of the crontab jobs (including errors) is sent through
        # email to the user the crontab file belongs to (unless redirected).
        # For example, you can run a backup of all your user accounts
        # at 5 a.m every week with:
        # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
        # For more information see the manual pages of crontab(5) and cron(8)
        # m h dom mon dow command
        @reboot /minecraft/


        1. Hi Twopeas,

          I’ve been looking into this issue.. When you setup the server, did you encrypt the home directories? That is the only way I found it to not work.. Try this…

          Make sure you are at the root directory where the Minecraft install is and move it all to the opt directory:

          sudo mv minecraft /opt/

          Edit the start script:

          sudo vi

          Enter the following:

          # Start the server
          java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
          # Log all reboot startups to keep track
          exec echo Minecraft server was started/re-started on `date` >> /var/log/minecraft.log

          Change crontab to reflect the change:

          crontab -e -u minecraft

          Change to the following:

          @reboot /opt/minecraft/

          Once the server is rebooted, run the following to make sure it works:

          cat /var/log/minecraft.log

          Let me know if this works for you, if it does, I will change the process to use /opt location instead.


  20. I have loaded the @reboot command to crontab but when I restart my server it does’t launch the minecraft server. I will be hosting multiple servers so an automated reboot will be a necessity but I can’t seem to get it to work with even one server. Any thoughts?


    1. Thanks for the feedback rightwingrb, can you try the last suggestion I noted for Twopeas and let me know if that helps?

      Make sure you are at the root directory where the Minecraft install is and move it all to the opt directory:

      sudo mv minecraft /opt/

      Edit the start script:

      sudo vi

      Enter the following:

      # Start the server
      java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
      # Log all reboot startups to keep track
      exec echo Minecraft server was started/re-started on `date` >> /var/log/minecraft.log

      Change crontab to reflect the change:

      crontab -e -u minecraft

      Change to the following:

      @reboot /opt/minecraft/

      Once the server is rebooted, run the following to make sure it works:

      cat /var/log/minecraft.log

      Let me know if this works for you, if it does, I will change the process to use /opt location instead.


      1. Sadly that didn’t help. I’m sure I am doing something wrong. Full disclosure, I changed the username from minecraft to my default username and I changed the name of the directory where the game is located. Those changes shouldn’t affect the commands that you are having me run as long as I change them accordingly in your script I wouldn’t think.

        The log however does work. I manually started the server and checked the log and there was an entry. So whatever is going on is in the cron script or I doubt that it is the .sh file though as it is really only one line to start the game server and the log file does work.

        As I indicated in my last post I have somewhat bigger plans than just hosting one game server. I am trying to learn how this all works because I want to start my own business.


        1. In the dir you have the server file, run this command and make sure that the server itself has the right permissions:

          ls -lah

          The files should show something like:

          -rwxrwxr-x 1 username username 8.0M Dec 9 07:49 minecraft_server.jar
          -rwxrwxr-x 1 username username 69 Dec 31 20:11

          You want to look for two things:

          the rwxrwxr-x and username username

          If those don’t look right run these commands to fix them:

          sudo chown username:username *
          sudo chmod +x minecraft_server.jar
          sudo chmod +x


  21. Wouldn’t let me reply to your last comment but here is what I have using the ls -lah command. The server.jar file had the wrong rights but even after changing them it still doesn’t work.

    rightwingrb@MinecraftServer:/minecraft$ ls -lah
    total 9.4M
    drwxrwxr-x 6 minecraft root 4.0K Jan 10 12:31 .
    drwxr-xr-x 23 root root 4.0K Jan 10 12:06 ..
    drwxrwxr-x 2 minecraft minecraft 4.0K Jan 10 12:06 backups
    -rw-rw-r– 1 minecraft minecraft 2 Jan 10 17:48 banned-ips.json
    -rw-rw-r– 1 minecraft minecraft 2 Jan 10 17:48 banned-players.json
    -rw-rw-r– 1 minecraft minecraft 180 Jan 10 12:15 eula.txt
    drwxrwxr-x 2 minecraft minecraft 4.0K Jan 10 17:48 logs
    -rwxrwxr-x 1 minecraft minecraft 9.4M Jun 5 2015 minecraft_server.jar
    -rw-rw-r– 1 minecraft minecraft 139 Jan 10 17:48 ops.json
    -rw-rw-r– 1 minecraft minecraft 780 Jan 10 17:48
    drwxrwxr-x 8 minecraft minecraft 4.0K Jan 10 17:49 TestServer
    -rw-rw-r– 1 minecraft minecraft 110 Jan 10 17:48 usercache.json
    -rwxrwxr-x 1 minecraft minecraft 66 Jan 10 12:31
    -rw-rw-r– 1 minecraft minecraft 2 Jan 10 12:15 whitelist.json
    drwxrwxr-x 7 minecraft minecraft 4.0K Jan 10 12:17 world


    1. rightwingrb,

      Can you let me know under which user you are running the cron job?

      Also, is the server to be worked with rightwingrb or minecraft or a different user? The reason being that the same user that will be running the cron job should have permissions to the Minecraft items.

      Apart from that I’m not 100% sure what to look for seeing that I don’t have access to the server to diagnose. I tried prior to figure out and once I moved all my files to the /opt/minecraft directory and verified the permissions it all worked fine.

      I’ll continue to look around on my server to see if I can figure out another workaround.


      1. Ideally I would like to use it with the rightwingrb account. In reality I will do it under whichever account I can get it to work with.

        How do I verify which account is trying to run the cron job? Also which account should be running the job?


        1. If you want to use rightwingrb as the general account just go to one directory above the minecraft directory, for example:

          If your minecraft files are located in /minecraft) do the following:

          cd /

          If your minecraft files are located in /opt/minecraft) do the following:

          cd /opt

          Then run the following command to grant proper permissions:

          sudo chown -R rightwingrb:rightwingrb minecraft

          Then as the user rightwingrb, run this:
          crontab -e

          Now add the line to allow the start script to run. Make sure to set the location to wherever you have the script. The cron job should be ran by the same user that is set for the minecraft server.


              1. no It isn’t working yet. I have been doing some research in other places on the interwebs to see what I may be missing. I’m going to try to do more with it when I get home tonight. If I have any success I will let you know.


  22. Hi, i tried to install, but when I run first the server and I try to log in, it says:
    [19:13:22] [User Authenticator #1/INFO]: Disconnecting /MYIPADDRESS:57687: Failed to verify username!
    Exception in thread “User Authenticator #1” java.lang.NullPointerException
    at lo$
    [19:13:22] [Server thread/INFO]: / lost connection: Failed to verify username!

    Can you please help me, what to do? Unfortunately Im not a linux expert, I just try to do step by step as you guided.

    Thanks and regards


    1. Moha,

      Thanks for using my tutorial and hope it was useful for you. How are you trying to connect to the server?

      If you are connecting from Minecraft you will need to use your Mojang/Minecraft account to log in. If you are trying to get back into the server to do admin work then you will only need to ssh into it with the user account you created when you setup the server.


  23. Your tutorial on setting up a Minecraft server on Ubuntu is great, I’ve followed it and got my server running without errors. Unfortunately, I have not been successful with connecting to the server from a local or external client. Each time results in a rare connection, a Minecraft authentication servers are down, or most commonly an io.netty~connection refused error.
    I have made sure that my antivirus was not blocking the connection, there were no firewall configurations in the managed network switches I am using, and I’ve even tried disabling UFW to see if that was the problem. All to no avail. I know the problem is server-side now, but I have run out of ideas of what might be causing this. Any thoughts?


      1. Marabar,

        Sorry for not replying earlier but it’s been a super busy end of 2017 and start of 2018. This issue normally happens when the auth servers are actually down for maintenance but it also happens when the IP address changes, I would suggest assigning a static IP to the server. I will update the article to include how to assign a static IP. I’m happy that you were able to figure this out.

        Thanks for the note and bringing this up so I can expand the article to cover more points for the build.


Share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.