August 7, 2012

Beginner

How To Set Up a Minecraft Server on Linux

Tagged In: Miscellaneous
Setting up a Minecraft server on Linux (Ubuntu 12.04) is a fairly easy task on the command line.

When choosing your server, be sure that it has (at a minimum)1GB of RAM, preferably at least 2GB.

The first thing you need to do is to connect to your server through SSH. If you are on a mac, you can open up Terminal, or if you are on a PC, you can connect with PuTTY. Once the command line is opened, login by typing:
ssh username@ipaddress

Enter the password when prompted. Although you can set up the server on the root user, it is not as secure as setting it up under another username. You can check out this tutorial to see how to add users.

Step One—Install the Requirements


Before going further, we should run a quick update on apt-get, the program through which we will download all of the server requirements.
sudo apt-get update

After that, we need to be sure that Java is installed on our server. You can check by typing this command:
 java -version

If you don’t have Java installed, you will get a message that says "java: command not found". You can, then, download java through apt-get:
sudo apt-get install default-jdk

You also need to supply your server with Screen which will keep your server running if you drop the connection:
sudo apt-get install screen

There is a complete guide on how to install and use screen here.

Install the Minecraft Server


Start off by creating a new directory where you will store the Minecraft files:
mkdir minecraft

Once the directory is created, switch into it:
cd minecraft

Within that directory, download the Minecraft server software:
wget -O minecraft_server.jar https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar

Since we have installed screen, you can start it running (-S sets the sessions title):
screen -S "Minecraft server"

After the file downloads, you can run it with Java:
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

The launching text should look something like this:
2012-08-06 21:12:52 [INFO] Loading properties
2012-08-06 21:12:52 [WARNING] server.properties does not exist
2012-08-06 21:12:52 [INFO] Generating new properties file
2012-08-06 21:12:52 [INFO] Default game type: SURVIVAL
2012-08-06 21:12:52 [INFO] Generating keypair
2012-08-06 21:12:53 [INFO] Starting Minecraft server on *:25565
2012-08-06 21:12:53 [WARNING] Failed to load operators list: java.io.FileNotFoundException: ./ops.txt (No such file or directory)
2012-08-06 21:12:53 [WARNING] Failed to load white-list: java.io.FileNotFoundException: ./white-list.txt (No such file or directory)
2012-08-06 21:12:53 [INFO] Preparing level "world"
2012-08-06 21:12:53 [INFO] Preparing start region for level 0
2012-08-06 21:12:54 [INFO] Preparing spawn area: 4%
2012-08-06 21:12:55 [INFO] Preparing spawn area: 12%
2012-08-06 21:12:56 [INFO] Preparing spawn area: 20%
2012-08-06 21:12:57 [INFO] Preparing spawn area: 24%
2012-08-06 21:12:58 [INFO] Preparing spawn area: 32%
2012-08-06 21:12:59 [INFO] Preparing spawn area: 36%
2012-08-06 21:13:00 [INFO] Preparing spawn area: 44%
2012-08-06 21:13:01 [INFO] Preparing spawn area: 48%
2012-08-06 21:13:02 [INFO] Preparing spawn area: 52%
2012-08-06 21:13:03 [INFO] Preparing spawn area: 61%
2012-08-06 21:13:04 [INFO] Preparing spawn area: 69%
2012-08-06 21:13:05 [INFO] Preparing spawn area: 77%
2012-08-06 21:13:06 [INFO] Preparing spawn area: 85%
2012-08-06 21:13:07 [INFO] Preparing spawn area: 93%
2012-08-06 21:13:08 [INFO] Done (15.509s)! For help, type "help" or "?"


Your Minecraft server is now all set up.

You can exit out of screen by pressing
ctl-a d

To reattach screen, type
screen -R

You can change the settings of your server by opening up the server properties file:
 nano ~/minecraft/server.properties




By Etel Sverdlov

Share this Tutorial

Vote on Hacker News

Try this tutorial on an SSD cloud server.

Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more

Create an account or login:

83 Comments

Write Tutorial
  • Gravatar gonzo over 1 year

    thx for the file minecraft_server.jar

  • Gravatar Brian over 1 year

    Consider updating the tutorial to include the use of screen or tmux. # screen -t "Minecraft server" # java -jar minecraft_server.jar nogui Issue ctl-a D to detatch the screen and leave it running to reattach use screen -R This is absolutely super basic. There are good server startup/shutdown scripts here: http://www.minecraftwiki.net/wiki/Tutorials/Server_startup_script

  • Gravatar Moisey over 1 year

    Great suggestion about wrapping it in a screen, we'll get the article updated for that.

  • Gravatar me about 1 year

    Thanks this was the easiest walk thru and it worked for me on a headless Ubuntu 12.04.1 Server LTS, via SSH from a Linux Mint machine.

  • Gravatar Moisey about 1 year

    Awesome =]

  • Gravatar carblob1234 about 1 year

    How do you play on your own server? just type in your ip?

  • Gravatar carblob1234 about 1 year

    I mean, i get how it's set up and all right now, but how do you play on the world with your friends? and is this worldwide or LAN? I am on ChrUbuntu 12.04.2 LTS. Please reply soon. Thanks! P.S my mc is on 1.4.7 if that makes any difference.

  • Gravatar Liam Cottle about 1 year

    Once your server is created and is running, to play you just open up MineCraft on your home computer and select Multiplayer at the start screen and then connect to your server with your IP address or with domain name if you have pointed a domain to it.

  • Gravatar Mees Pepijn van Dijk 12 months

    I've done this all and everything works but the server keeps saying: "[WARNING] Can't keep up! Did the system time change, or is the server overloaded?" Even though the server is empty?

  • Gravatar Alex Garrett 12 months

    @Mees Pepijn van Dijk Do you have enough RAM? Try adding swap.

  • Gravatar Mees Pepijn van Dijk 12 months

    @Alex Garret I have 1GB RAM and i'm afraid thats not enough, and how do i add more swap?

  • Gravatar Kamal Nasser 12 months

    @Mees Pepijn van Dijk: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04 The process should be the same for all Linux operating systems.

  • Gravatar skillswiper 11 months

    Help! I followed the instructions but i am trying to pull out to see my IP in the server config file with the ctl-a D command but it brings me to a black screen with no text. Plz help

  • Gravatar William 11 months

    When using "screen", and using the detach function, it should be taking you back to a prompt, where you could type "ifconfig" to see the IP addresses. Also, if you go into yiour digital ocean control panel, you should be able to see the IP address assigned to your server beside the name of the droplet.

  • Gravatar lghettie 11 months

    it keeps telling me connection refused

  • Gravatar lghettie 11 months

    what do i do

  • Gravatar Kamal Nasser 11 months

    @lghettie please open up a support ticket

  • Gravatar albert 11 months

    I've got it running, and it shows up in minecraft multipplayer. But it won't let me connect! Any ideas?

  • Gravatar Kamal Nasser 11 months

    @albert do you see any kind of error saying why you're not able to connect?

  • Gravatar Ryan Durbin 10 months

    is there enough proc power in 1gb dropplet to host a mc server? anyone have any expertience?

  • Gravatar Kamal Nasser 10 months

    @Ryan: You can spin up a 1GB droplet and see if it works fine. You can always scale up if needed. I believe it should be enough for a minecraft server with minimal load.

  • Gravatar Salvador Labajos 10 months

    which Java is installed with "apt-get install default-java"? OpenJDK or Oracle Java?

  • Gravatar Kamal Nasser 10 months

    @labajos.salvatore: OpenJDK will be installed by default. You can follow this article to install Oracle Java 7: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

  • Gravatar 212nath 9 months

    How do I update Minecraft to the latest version

  • Gravatar Kamal Nasser 9 months

    wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar That command should download the latest stable version. If you want to use another version, replace minecraft_server.jar with the one you want to use.

  • Gravatar gtawwekid 9 months

    Exit out of it?

  • Gravatar Kamal Nasser 9 months

    @gtawwekid: I'm not sure what you mean - do you want to exit the minecraft server after starting it in a screen session?

  • Gravatar mpeet 8 months

    When i do "nano /minecraft/server.properties" to get onto the server properties, it shows up blank with weird symbols at the bottom??! Wat doo i du

  • Gravatar Kamal Nasser 8 months

    @mpeet: Try this command instead:

    nano ~/minecraft/server.properties
    I've also updated the article.

  • Gravatar knappjt+do 8 months

    Please put a written/edited date on your blog posts, and thanks for having awesome hosting!

  • Gravatar chineside 8 months

    Great tutorial. It will help in my quest to set up a minecraftEdu server for my kid's school. I'm great on Commodore 64's and the Apple IIc but the 30 year break has taken it's toll. I'm sure whoever writes a tutorial for the average computer-semi-literate teacher will open the floodgates for the minecraft-education platform in classrooms. Anyone from Digital Ocean that can tell me if a remote server using Digital Ocean can meet the requirements to host 24 ish students?

  • Gravatar Kamal Nasser 8 months

    @chineside: Thanks for the feedback :] According to

    http://canihostaminecraftserver.com/
    , a 512MB droplet can host ~7 users at once. Try running the minecraft server on a 1GB or 2GB droplet and see how it goes.

  • Gravatar chineside 8 months

    For anyone wishing to start a new minecraft server in under 5 minutes, this is a great tutorial. The version currently linked to this tutorial is 1.5.2. Too old a version for my client. I gave up trying to find a link for a 1.6.2 version, and gave up trying move a download jar file and put it on my droplet , but had great fun trying. Appreciate being able to try this at almost no cost or commitment, and will certainly try again.

  • Gravatar Kamal Nasser 8 months

    @chineside: This article installs the latest stable version. As far as I know, Minecraft 1.6.2 is still beta

  • Gravatar blake.asher.sharp 8 months

    I can I don't know the stuff is not working HELP ME

  • Gravatar blake.asher.sharp 8 months

    i'm bad i've been trying alot can you update it or just send me one for Noobs????PLZ

  • Gravatar Kamal Nasser 8 months

    @blake.asher.sharp: Which part isn't working? Do you get any errors?

  • Gravatar PET 7 months

    Thanks for this. Did everything here, then I noticed it's an old version of minecraft. Decided to get the new one. I had to look on how to delete my old minecraft folder. Created a new one. Got the new jar file. Got error installing the new jar. Figured it out that I need to write the JAR filename, I was only writing ...minecraft_server.jar nogui and not ...minecraft_server.1.6.2.jar nogui Did that got an error message because not enough memory Figured it out that I have a process or something already in memory. Wrote "top". I saw minecraft there. Figured out how to kill the process. Installed the new JAR file. It was a good first day learning linux :D

  • Gravatar mattias.wahlberg 7 months

    Any tips on how to create an autostart script that starts minecraft after a power cycle? Would be great to have when using the API for power_on/power_off.

  • Gravatar celso.info 7 months

    Sorry for the basic question but I know nothing about minecraft. I'm trying to install it to my son. So, I could install everything. The question is How can I play now ? Thanks

  • Gravatar benjamin.leedy 7 months

    Once the server is up and running, if I close my SSH session, then reopen it, how do I reconnect to controlling the server? Is there a screen command for that? I tried "screen -R" but it opened a new screen.

  • Gravatar Kamal Nasser 7 months

    @benjamin.leedy: We have an article on using screen here: https://www.digitalocean.com/community/articles/how-to-install-and-use-screen-on-an-ubuntu-cloud-server

  • Gravatar Kamal Nasser 7 months

    @celso.info: Once you've set up the minecraft server, you can connect to it by creating a new minecraft multiplayer server on the minecraft client and setting its address to your droplet's IP address.

  • Gravatar Dan Thorberg 7 months

    I've got the 1GB server and have trouble running even 4 people at the same time. I'm getting a java out of memory (Kill process #### error) anybody else running into that problem with Java, I'd think 1GB would be okay for a small amount of people?

  • Gravatar Kamal Nasser 7 months

    @Dan: Do you have any other processes/services running on your droplet?

  • Gravatar Dan Thorberg 7 months

    Unfortunately no its a shake and bake Ubuntu install with Minecraft running. I have a LAMP server running but its not getting any access. I just setup the Swap file well give that a go and see if it makes any difference.

  • Gravatar Kamal Nasser 7 months

    @Dan: 1GB is certainly not enough for apache, mysql, and minecraft. I recommend setting up minecraft on a separate droplet without any other services and without a swapfile as it degrades minecraft's performance.

  • Gravatar raymond.yee 6 months

    For those of you who use ansible, I've posted a IPython notebook to show I implemented the instructions in this post: http://nbviewer.ipython.org/7011434. Now I can programmatically spin up a droplet to run minecraft.

  • Gravatar itisme_right 6 months

    for anyone worrying about getting the 1.6.4 version then here is the link for it: https://s3.amazonaws.com/Minecraft.Download/versions/1.6.4/minecraft_server.1.6.4.jar

  • Gravatar crlsmtzprds 4 months

    This post help me to config my Ubuntu server and now I have my personal Minecraft Server... and that's cool.. but the question of Million: How install mods on terminal for this minecraft server?

  • Gravatar Kamal Nasser 4 months

    @crlsmtzprds: See https://www.digitalocean.com/community/articles/how-to-use-filezilla-to-transfer-and-manage-files-securely-on-your-vps.

  • Gravatar Simon.safferson 4 months

    I can't connect to the server. When I look what It says in the putty it just says "disconnecting (my ip adress here) protocol error". What does that mean? I also think that my server is outdated. I play with 1.7.4 version and it says that my version on the server is 1.5.2 so I'm not sure how to fix that.

  • Gravatar Simon.safferson 4 months

    ergh.. I think my question is.. Is there any way to update bukkit (I guess?) to the latest version?

  • Gravatar Kamal Nasser 4 months

    @Simon.safferson: Download the minecraft server jar version 1.7.4 and replace minecraft_server.jar with it.

  • Gravatar Simon.safferson 4 months

    Found that now, thanks! I have another question though. My friend placed TNT all over the place and now my spawn is a bit destroyed. Is there any way I can fix so I have a new spawn? Or a new world even?

  • Gravatar Kamal Nasser 4 months

    @Simon.safferson: You can cd to your minecraft directory

    cd ~/minecraft
    and remove the current world and then restart minecraft_server.jar so that it generates a new one. Keep in mind that once you run this command you can't undo it:
    rm -r world
    You can also move it to a backups directory in case you need it later: Create the backups directory:
    mkdir ~/world_backups
    Move it there:
    mv world ~/world_backups/world_name
    You can choose any name you want as long as you know that it's this specific world.

  • Gravatar Simon.safferson 4 months

    This is confusing for me, I don't know how to do it using Putty. I wish I had someone that could explain to me while I livestream my screen or whatever. Thanks for the help though!

  • Gravatar Jason 4 months

    I'm running a minecraft server alongside Apache and MySQL (I have a WordPress site up) with a 512 droplet but I'm only allocating 256 to minecraft (java -Xmx256M -Xms256M -jar minecraft_server.jar nogui). My son and 2 of his friends are able to play with no reported problems. I do occasionally see warnings about "Can't keep up!" but when I talk to my son about it he says he doesn't see any problems. So until he complains, I'm not too worried about using only 256M. If he does start complaining I'll probably just create a new Droplet with 1GB of RAM and whenever I take down the server (it's only on while they play on the occasional Saturday) I'll create a snapshot first and it will be a fairly minimal cost.

  • Gravatar post 4 months

    Hey, not sure if it was just me, but wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar did not get me the latest version of minecraft. had to go here: https://minecraft.net/download to get it.

  • Gravatar mrjoshua0677 4 months

    I have set up everything and it works perfectly, the only thing I cannot do is get minecraft to recognize my son as an admin. I have put his name in the ops.txt, there is no admins.txt in 1.7.4. I am not sure why. Everything I read tells me the same thing.

  • Gravatar Kamal Nasser 4 months

    @mrjoshua0677: Try creating the admin.txt file and adding your son's username to it. Does that work? (Make sure you restart minecraft).

  • Gravatar Greg K 3 months

    Awesome article, other than switching to grab the latest copy of the MC server as mentioned in a comment, followed it exactly, and it worked great on a fresh didcated 2g droplet, until.... Two of us were using it with most of the time a server load of .45, occasionally spiking higher, but not staying there. Then we built a trap for a zombie spawner we found, which ended up crashing out the server. If I start it up now, load is usually over 1, usually around 1.5 (with just me).. I managed to run down, and holy crap the number of zombies... Anyhow, the server just stops, probably due to some load issue, but can't find out any type of errors to indicate why to try to troubleshoot. If you could provide any help on where to look for errors and such, would love it.

  • Gravatar Greg K 3 months

    Clarification: The minecraft server, not the linux server is what is crashing/stopping

  • Gravatar Kamal Nasser 3 months

    @Greg: Try adding swap, your droplet could be running out of RAM: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04 Make sure you follow the part where you set the swappiness level to 0 otherwise your minecraft server's performance will be affected.

  • Gravatar spamidy 3 months

    is there a way i can write a bash script from my default user, to execute the java command as the mcserver user and therefore start the server? I've tried writing a script where the first line is sudo login, then after that is the java command, but when i run that sudo login java -Xmx1024M -Xms1024M -jar /home/mcserver/minecraft/minecraft_server.jar nogui it just logs me into the mcserver user, it doesn't start anything. I've also tried using this command: sudo -H -u mcserver bash -c 'java -Xmx1024M -Xms1024M -jar /home/mcserver/minecraft/minecraft_server.jar nogui' and text scrolls by with errors until i stop it. the errors all say this. at lj.a(SourceFile:41) [minecraft_server.jar:?] at lj.b(SourceFile:51) [minecraft_server.jar:?] How would you recommend writing a bash script that will, in the terminal, login to another user, then start the server with the java command? Effectively, I want the same result as typing in sudo login, then the credentials and then the java command. Thanks -Drew

  • Gravatar KAT 3 months

    Minecraft runs well for a while but then after about 10-15 minutes randomly quits with the following error: internal exception: java.IOException: an existing connection was forcibly closed by the remote host Any ideas that could help?

  • Gravatar kylee 3 months

    I did this and the server seems to be up but it is version 1.5.2 and i cannot connect. How do i update it to 1.7.4?? This guise seems to be the only helpful one i could find besides that...

  • Gravatar Kamal Nasser 3 months

    @KAT: It probably crashed, try adding swap: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04. Does that fix it?

  • Gravatar Kamal Nasser 3 months

    @kylee: Try downloading the latest version:

    wget -O ~/minecraft/minecraft_server.jar https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar

  • Gravatar vadiola 3 months

    getting this error : [Server thread/INFO]: GameProfile{id='null', name='username'} (/192.168.2.15:53971) lost connection: Disconnected how to solve it???

  • Gravatar vadiola 3 months

    solved!

  • Gravatar kylee 3 months

    Would i then use the same command to run it? Also, should i delete the old version?

  • Gravatar downballplayer 3 months

    lol this doesnt work. it crashes with like 4 people on default and i know for a fact its not the ram because a windows server with 1gb ram can run this with like 20 people without lag.

  • Gravatar Kamal Nasser 3 months

    @kylee: Yes. You need to run the command I posted once and it should update the server to 1.7.4. The rest of the commands are the same as in the article.

  • Gravatar phantomon 2 months

    Do you have any tutorial or list of mods for this minecraft-server.jar? I'm a newie in this and I'd like to start modifying with mods in the server. I have placed the server in a VPS and works just great, I also tested the server with 8 users at the same time and there is no lag. But I'd like to add some mods. How can I do it or where can I find a mod for this server?

  • Gravatar Kamal Nasser 2 months

    @phantomon: You can either add mods by modifying minecraft_server.jar or you can use Bukkit which allows you to install plugins/mods by dropping them into a directory: http://wiki.bukkit.org/Setting_up_a_server. This should also help: https://www.digitalocean.com/community/articles/how-to-use-filezilla-to-transfer-and-manage-files-securely-on-your-vps.

  • Gravatar Thierryfox60 about 1 month

    whenever I run the jar server file (in a folder) the files are not made? I only see the jar file and I dont see the server properties or anything. I also tried to look in the jar file to see if its in there but I dont see it.

  • Gravatar Thierryfox60 about 1 month

    Oh, I've figured it out now, its in the /home/yourname folder and the ctrl and h to show the hidden files

  • Gravatar Simonmyhl about 1 month

    Hey kamal how to I delete the minecraft server from my ubuntu server completely? i have tried to remove the folder "minecraft" but when i open minecraft and press multiplayer the server is still running but i cant connect. How to i make en server minecraft server on my ubuntu server`?

  • Gravatar Kamal Nasser about 1 month

    @Simonmyhl: You need to stop it first. Run

    screen -r
    and then type stop and press enter.

  • Gravatar Dashel Lathers about 1 month

    This was a big help, thank you!

  • Gravatar rubelonepabna about 1 month

    This giddiness are not working on my Ubuntu 13.10 non lts version. Can you please provide my a video guide ? it will be very helpful for me. Rubel Hossen

  • Gravatar mihai041079 25 days

    When i go back screen -R, I cant write command "stop" for stopping the server..

Leave a Comment

Create an account or login:
Ajax-loader