Installing Minecraft Server in Ubuntu Server
by firestorm_v1 on Jan.09, 2011, under How-To's, Linux, Software
Ok, I’ll admit it. I’ve been caught by the Minecraft bug. It bit me hard and of course I learned rather quickly that there is a problem with using two laptops to play Minecraft on and that is that it’s a pain in the posterior to move your save games around. In this article, I will be covering how to install Minecraft Server on a new installation of Ubuntu 9.04LTS. These instructions will work for all current versions of Ubuntu, so if you’re using something newer or something older, these instructions should get you up and running in no time.
Foreword
Please note that per Notch (the Minecraft developer), running the Multiplayer server is still in beta phase so expect it to crash, be buggy and generally not work. That being said, I can personally tell you that Minecraft Server DOES work and except for a few minor gameplay glitches, the server works quite well. Please keep in mind that this is by no means an exhaustive article on all things Minecraft Server, nor is it written in stone (ba-dum-thish!) as the Minecraft Server application may change. If it does, I will make changes to this article to keep it current.
I can tell you that having your own Minecraft server is awesome and that you will never go back to playing singleplayer as you won’t have to worry about files to migrate and that your world will continue to evolve even as you are not playing. This being said, before you disconnect your Minecraft session, it is recommended to make sure that your minecraft player is somewhere safe, be it in your bunker or somewhere where baddies can’t get to you while you are away. Remember, just because you’re not logged in, doesn’t mean that the world stops.
System Requirements
The System Requirements for Minecraft Server have yet to be officially established however there are some guidelines that have turned up during my research into this topic. The below is a guideline only and not an exhaustive set of requirements. It’s perfectly fine if you don’t meet all of them however expect performance hits depending on how you use the server.
- Processor: At least a 1.5GHz single core chip, whichever architecture you desire.
- RAM: At least 1.5GB FREE RAM. If you use the server for anything more than Minecraft, make sure you have at least 1.5GB free RAM at full utilization.
- Disk: At least a 20Gb disk, with swap space allocated. (Using the “Use Full Disk” and “Automatically Setup Partitions” options in the Ubuntu Setup will ensure you have enough swap. Although the game isn’t that big, the save files and caching elements will be quite large so of course the more the merrier.
- Networking: 10/100 Ethernet is recommended.
- Video: Doesn’t matter. We will be running Minecraft Server in a Screen session, so there’s no need for a fancyOMGWTFBBQ video card. Save that for the rig you will play Minecraft on.
Please note: In order to take advantage of Minecraft Server, you must purchase the game from Notch at www.minecraft.net and have a username and password. You will still need to use either the Minecraft Beta standalone application or the Minecraft Beta web-based application to access your server.
This is the basic setup of a good single person Minecraft server. While the possibility exists that you may be able to run multiple connected players on the specs above, if you are planning on hosting a lot of players, you may want to consider a beefer rig. My Minecraft server uses the below stats:
- Processor: Dual Core Intel Core 2 Duo 1.86GHz
- RAM: 3.5GB DDR-2
- Disk: 80GB SATA
- Networking: 10/100/1000 Ethernet (onboard)
- Video: whatever’s on the motherboard.
Getting Started
This HOWTO will already assume you’ve installed your core Ubuntu Server installation and have performed no additonal steps. Login with your user account that you created during setup and perform the following steps. While you can technically prepend “sudo” to each command, I find it faster and less frustrating to just “sudo bash” and type your password once.
- apt-get update
- apt-get install openssh-server
- apt-get install screen
This will install the OpenSSH server so you can remotely manage the server. You will need a client like PuTTY (download from here) in order to access it. This will also install Screen which will contain the Minecraft server process. If you don’t install screen, you will not be able to exit the SSH session without the Minecraft server being killed off.
Now for the fun part. You will need to install Java in order to start the Minecraft server but Minecraft server will require the use of only the Sun JVM. I tried with the other JVM and it did not work at all.
- apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre
In order to ensure that the java environment is correct, run the command “java -version” and make sure it matches the below text.
# java -version
java version “1.6.0_22”
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
If it shows something else, you will need to do the following:
- update-java-alternatives -l
This will list off all the various Java VMs that are installed.
# update-java-alternatives -l
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
You will need to set the proper Java VM to use via the below syntax:
- update-java-alternatives -s java-6-sun
Now, run “java -version” again and it should show the same version information as above. If it does, you’re good to go otherwise check your error messages.
Please note that the rest of these commands are run without root privileges. NEVER EVER RUN MINECRAFT SERVER AS ROOT!
Installing Minecraft Server
If you’re this far, then you’ve got the Java VM set properly and your server is all set for Minecraft Server. You will need to download the minecraft_server.jar to your computer then use scp to put it on the server. You can download a Windows SCP client called WinSCP from this site. Copy it into your non-root user’s home directory, in my case I’m using “mcserver”.
To start the server, you will need to use the following command:
-
java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
You will see a lot of text scroll past the screen and you will see it generate a new world via the console messages. Once it settles down, you can then type “help” for a list of commands.
Since we just fired it up, let’s go ahead and stop it. Type in the command “save-all” which forces the server to save the generated map, then “stop” to shut the server down.
Stopping and Starting the server
To start the server, first off make sure you are in a screen session by typing “screen -list” like below:
mcserver@mcserver:~$ screen -list There is a screen on: 2434.tty1.mcserver (01/09/2011 12:58:57 PM) (Attached) 1 Socket in /var/run/screen/S-mcserver.
This indicates that you are in a screen session. If you see “(no screens running)” then just type “screen” to start one.
Once in the screen session, type in the command shown below. This is the exact same command as when we installed it, but this time we’re not going to shut it down.
-
java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
To disconnect from the screen session, hit Ctrl-A and then the D key, this will drop you back to the shell prompt where you can then type “exit” to logout. The Minecraft Server will continue to run.
To stop the server that is already in a screen session, login to the server using SSH and the non-root user. To reconnect with the screen session, type in “screen -r”. You will be reconnected to the server and can then perform the following commands:
- say Server is going down
This lets any players know that the server’s going down.
- save-all
This tells the server to save the entire world.
- stop
This tells the Minecraft Server to shutdown and exit. You will be dropped to a console prompt from there you can shutdown the server or do whatever you need to do.
Other useful commands in MC Server
Console commands: help or ? shows this message kick <player> removes a player from the server ban <player> bans a player from the server pardon <player> pardons a banned player so that they can connect again ban-ip <ip> bans an IP address from the server pardon-ip <ip> pardons a banned IP address so that they can connect again op <player> turns a player into an op deop <player> removes op status from a player tp <player1> <player2> moves one player to the same location as another player give <player> <id> [num] gives a player a resource tell <player> <message> sends a private message to a player stop gracefully stops the server save-all forces a server-wide level save save-off disables terrain saving (useful for backup scripts) save-on re-enables terrain saving list lists all currently connected players say <message> broadcasts a message to all players
Quick and Easy Start script
Below is a very simple script I wrote because I kept forgetting all the java commands. In order to use it, save both lines below as a file (like “startmcserver.sh”) and then “chmod +x startmcserver.sh” so that way you can start the server simply by running “./startmcserver.sh”
#!/bin/bash java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
Remember to keep both lines intact. It’s essentially the same Java command, but it’s easier to type.
Have fun and Happy minecrafting!
FIRESTORM_v1
40 Comments for this entry
1 Trackback or Pingback for this entry
-
Gr3yh0und's Blog » Minecraft Server Installation on Ubuntu
August 28th, 2011 on 7:29 am[…] to firestorm for his older blog post, which I mostly adopted to my case. configuration installation minecraft minecraft server […]
January 9th, 2011 on 9:27 pm
the java files have been moved. I tried to download them from that location and it is incorrect. I did find them using
sudo apt-get install ubuntu-restricted-extras
January 10th, 2011 on 5:57 pm
Thanks!
I loved your walk through.
I had some trouble though, because when I checked my version, I got “java version “1.6.0_20” and I couldn’t seem to get it to update, It’s driving me crazy, because my server started to develop problems of crashing. Sometimes it’s java related, others I think it’s Ubuntu. If you’ve got any Ideas, I’m all ears. I can give you some error codes if you would like. I’m a little lost.
January 11th, 2011 on 1:57 am
@Nate:
Hmm, that’s a good question. If you haven’t done so recently, you might want to see if you can download the updated minecraft_server.jar from http://www.minecraft.net. Unfortunately, my server was built a couple of days ago and it’s been humming along with over 48 hour up time with no issues. Now if I could figure out how to better defend against Creepers, I’d be all set.
The server doesn’t announce it’s version number or anything like that, so the only thing I can suggest is to do an MD5sum of the minecraft_server.jar. My MD5 is 93ca0782aa1b903b43f2e8c685c91b4d
Good luck!
FIRESTORM_v1
February 11th, 2011 on 1:35 pm
Thanks for the tutorial. It has helped me get a minecraft server set up on Ubuntu 10.10 server.
I’ve run into an issue you may be able to help with.
After the minecraft server has been running for a while the chat stops working. The users will get kicked saying “Illegal characters in chat.” any time anything is typed.
There are no console errors. The only thing showing in the console is that they disconnected.
If I then try to stop and restart the server I get the following error:
Exception in thread “main” java.lang.NoClassDefFoundError:
I then have to restart the ubuntu box in order to fire up the minecraft server again.
Any thoughts?
March 22nd, 2011 on 11:09 am
Hello Mydnyte:
That’s a good question. Unfortunately, my MC Server is behind a firewall and is not publicly accessible. Is it possible that someone’s performing a noisy scan against your MC server and that there is input in the MC application that’s freaking out and crashing?
If it happens again, try running ps -fauwx and make sure that there is no Java/Minecraft processes. Restart Jetty if it’s running and try again. Chances are there’s some residual process that’s causing problems.
Good Luck!
FIRESTORM_v1
April 8th, 2011 on 10:31 pm
Hey Firestorm,
Great guide, I followed your steps and such. My question is how can I get other people on my server, it says to use port 25565 and I have forward it via the router but nobody can connect. Any ideas would be much appreciated and thank you again for the great guide.
June 3rd, 2011 on 9:33 am
@Cooksey – if the port is forwarded to the right IP there shouldnt be any trouble. Your friends should be able to connect via your.ip:25565
If they are unable you should check if you have any software firewall blocking. also check server.properties to see if whitelist=true, if it is you need to add their usernames in white-list.txt.
Hope you figure it out <3
June 7th, 2011 on 10:57 pm
I love how halfway through there is a problem in the steps that cannot be fixed, and that u never tell us how to use the ssh, now im completely stuck cuz u missed a crucial part, i dont ven know the username/port#/or password/ or even how to set up ssh.
June 8th, 2011 on 10:43 am
@Nick: I’m going to address your concerns on a step-by-step basis:
1) “there is a problem in the steps that cannot be fixed”
At no time did I say there was a problem that could not be fixed. Please elaborate.
2)” u never tell us how to use the ssh”
Chances are, if you’re playing with Linux, you already know how to use SSH. Since your comment indicates otherwise, I will tell you how to do it at the end of this reply.
3)”I don’t ven know the username/port#/or password/”
If you are starting off with a completely new installation of Ubuntu as stated in the beginning of the HOWTO, you were required to enter a username and password for account creation. You use the same username and password to connect to the server.
4)”… or even how to set up ssh.”
Setting up ssh is as simple as “apt-get install openssh-server” as outlined in the first few commands in the “Getting Started” section.
Using SSH:
As stated before, during the installation of Ubuntu Server, you were required to create a username and password. You will need to use this username and password to connect to the server. Another step in the Ubuntu installation process is to set up networking. If you assigned a static IP address then you will need this address to connect. If you accepted defaults and used DHCP, then you will need to check your router’s configuration and look for DHCP IP addresses. Alternatively, just login to the server’s console and run “ifconfig”. My instructions for installing OpenSSH did not cover any changes to the stock configuration so the default service port for SSH is 22.
Now you should have the needed information. You have the username and password (created during Ubuntu installation), IP address (either through static IP or DHCP) and since the Openssh configuration is stock, you have the port.
My instructions cover getting a copy of PuTTY. Download that file and run it, it is an SSH client for Windows. On the main window, you will be prompted for the IP address and the port number as well as the connection method (SSH). Enter the information, hit Connect and you should be at a username prompt.
I hope this helps.
FIRESTORM_v1
June 23rd, 2011 on 3:51 am
Did everything up to getting the server to start. I keep getting the error “Unable to access jarfile minecraft_server.jar
June 26th, 2011 on 12:37 pm
So to start – I am a mac user and also a minecraft fan. As I wanted to setup a minecraft server on mac I just couldn’t find a proper info on the subject. Until I came upon this site: http://minsrv.com – clearly writen, with some print screens – all neat and understandable 🙂 I bet it can help You. BTW: it is still developing.
July 18th, 2011 on 7:37 pm
Joshua you have to download another minecraft_server.jar, put it in the original minecraft
server folder
July 25th, 2011 on 2:28 am
Thank you for the great tutorial! I would just like to share an update script I just built.
#!/bin/bash
rm minecraft_server.jar
wget http://www.minecraft.net/download/minecraft_server.jar
I named it mcupdate.sh and did a chmod +x mcupdate.sh
July 27th, 2011 on 10:36 pm
Im still confused. Where can I find the correct version of java?
July 27th, 2011 on 10:38 pm
I’m still confused. Were can I find the correct version of java?
August 15th, 2011 on 7:29 am
Awesome tutorial. I have a server set up, but was having some other problems (being able to admin remotely). This fixed those problems.
Any thoughts on craft_bukkit? Worth it? Not worth it? I tried it, and stuff started crashing more, but that might have been something else.
August 18th, 2011 on 1:33 pm
If you wanted to change the server.properties, how would you do that? Because there is to GUI
August 26th, 2011 on 1:34 am
Thanks a ton for the tutorial. Just bought a dedicated server with some of my friends for our Minecraft server. Installed Ubuntu server, and have been having some slight troubles. This fixed the last of them.
Thanks!
August 26th, 2011 on 11:38 am
The server.properties file is a flat text file. You can use any text editor to edit it.
August 26th, 2011 on 11:41 am
Hey Johnny! Glad to hear that your server’s up and running. Have fun with Minecraft!
August 30th, 2011 on 9:23 pm
@mcargent
I currently host a server using craftbukkit and it’s running fine. Although I will admit it has taken a lot of time getting it to work, I think it’s worth it. Make sure when you edit plugin .yml files that you never use [tab]. That’ll always screw things up.
September 17th, 2011 on 4:04 am
@Abteen
“If you wanted to change the server.properties, how would you do that? Because there is to GUI”
I presume you are fairly new to command line linux, so to edit a text file you need (as FIRESTORM_v1 said) a text editor, if you are still confused as to what to do its quite simple;
First go to your Minecraft directory, then type:
vi server.properties
This will open the file in the vi text editor.
vi is fairly easy to use for example hit “i” to go into edit mode, and to get out of edit mode hit the Esc button, to exit type “:q” and to save and exit type “:wq”.
Here is a webpage with more commands:
http://www.cs.colostate.edu/helpdocs/vi.html
(InsaneOracle/)
October 13th, 2011 on 7:55 pm
Thanks for the info, I followed instructions but I can’t run a “private, no internet minecraft server” I get the following error:
failed to load Main-Class manifest attribute from minecraft-server.jar
I guess to have a jar file that requires internet access.
October 17th, 2011 on 8:06 pm
Hey Rick:
This doesn’t appear to be an internet connectivity issue as a corrupted JAR file. Check that you’re running the Sun Java JVM and not the OpenJava version and/or re-download the jar file.
Good luck!
October 31st, 2011 on 7:36 pm
How do you get the minecraft_server.jar file to the ubuntu server???
November 1st, 2011 on 6:39 pm
Hello jon:
I used “wget” to get the file into the server. First I went to the minecraft.net site, logged in, then clicked on “download”. On that page, somewhere near the bottom, there is a link that points to the current minecraft_server.jar file. I right-clicked on it, went to “Copy Link Location”, then just pasted it after the wget line in my terminal session to the server. It should look something like below:
# wget http://minecraft.net/download.php?hash=1234567890 (Yours will probably be different)
Once it downloaded, then I was able to run it with no issues.
Good Luck!
FIRESTORM_v1
December 6th, 2011 on 9:52 am
Ubuntu 9.04 has no Long Term Support, 8.04 and 10.04 are LTS. B)
December 7th, 2011 on 8:09 pm
Hello Vortakor:
You are correct. At the time that this article was written, Ubuntu 9.04LTS was long term, unfortunately it has been EOL’ed and mothballed. These instructions are still valid for all versions of Ubuntu (workstation or server).
Happy mining!
FIRESTORM_v1
January 17th, 2012 on 6:30 pm
Hey, I just wanted to share this script I found. http://dl.dropbox.com/u/16648/minecraft_installer.sh
Just sudo chmod 755 minecraft_installer.sh it and do ./minecraft_installer.sh –install-server
June 6th, 2012 on 1:38 pm
Hello NivthK:
That looks to be a pretty useful script and may work for some setups however I recommend McMyAdmin for large scale deployments and have been meaning to write a post on how to migrate an existing Minecraft server to McMyAdmin. Thanks for the tip, that should definitely work for anyone just wanting to get up and running quickly.
Thank you.
FIRESTORM_v1
June 23rd, 2012 on 1:23 pm
Hi I know you probably won’t want to do this but I am a complete linux noob and you sound very knowledgable so I was wondering if you’d make a youtube video explaining this process in detail.
June 23rd, 2012 on 2:05 pm
Hello Luke:
Actually, the thought hadn’t occurred to me to try a howto video. This method is actually deprecated as with just a little bit more effort of installing McMyAdmin, you get a web-based admin console that is really easy to use. As soon as I get some free time, I’ll post an updated article on how to perform a full install from a stock Ubuntu server. It’s honestly not hard, just intimidating. The worst that could happen is the server not work.
Stay tuned,
FIRESTORM_v1
June 23rd, 2012 on 5:18 pm
Wow thanks that sounds great, I’m so glad I found this page as I’ve been looking into it for a while. If you show this new method using McMyAdmin do you think you would do a video as well as a description method as, although it might just be me, I find video howto’s much easier to follow. Anyway whichever way you choose to do it I think I’ll hold off this method for now and wait. Cheers
Luke
P.S Heres my email:
[[Moderator Removed, don’t want you to get spammed]]
If you would mind sending me an email if you decide to post anything else.
June 28th, 2012 on 4:36 pm
Wow thanks that sounds great, I’m so glad I found this page as I’ve been looking into it for a while. If you show this new method using McMyAdmin do you think you would do a video as well as a description method as, although it might just be me, I find video howto’s much easier to follow. Anyway whichever way you choose to do it I think I’ll hold off this method for now and wait. Cheers
Luk
July 21st, 2012 on 8:26 pm
thanks for the awesome tutorial i am going to run this through virtualbox a video sounds great please post a link
July 23rd, 2012 on 11:08 am
Hello Luke:
An updated Minecraft server article is in the works and it will have video if I can get it working. 🙂
FIRESTORM_v1
July 23rd, 2012 on 11:11 am
Hello Nerwall:
I tested this out on Virtualbox and did notice that there was some minor lag. Not enough to seriously affect gameplay however it was more noticeable where you were exploring a new area and the terrain generator had to run. Provided you’re not skimping on your VM settings (2GB RAM minimum from testing), you should be fine.
Have fun!
FIRESTORM_v1
July 23rd, 2012 on 11:54 am
Hello Luke:
I mirror my posts with my site’s Facebook page facebook.com/YourWarrantyIsVoid so any posts I make get posted there. I currently have several projects in the mix however the video/tutorial of McMyAdmin is definitely on one of the upcoming ones.
Stay Tuned!
FIRESTORM_v1
August 25th, 2012 on 9:20 am
When I tried to install java i got this error message…
E: Unable to locate package
What happened?
November 2nd, 2012 on 6:43 pm
Hello Ethan:
It appears that Ubuntu and Sun got pissy with each other and removed it from the repository from what I’ve heard. You may be able to get around it by adding “non-free” to the repository lists in /etc/apt/sources.list but I’m not sure what to do past there. The standard debian package may work, but that requires a manual installation.
Good luck.
Firestorm_v1