Recently I wrote a guide on how to install a Minecraft Server on Linux, check it out if you havn't got your own Minecraft Server yet!
This post will teach you how to, in a very simple way, make your Minecraft Server run as a daemon in the background instead of consuming a terminal and making it hard to remotely control the server.
1. What you'll need.
First off you need to set up a Minecraft Server, SSH, FTP and java environment. After that you'll need to download and install GNU Screen. For me Screen was somehow already installed on Ubuntu, so I didn't have to do that, but if you need to install it I think the code is "sudo apt-get install screen". To check if you got screen installed, type "screen -v" (displays the version, if any).
2. What is Screen?
GNU Screen is a utility that lets you run "multiple terminal windows" (excuse my very bad tech jargon here) inside a single terminal. You can see it as being able to switch through multiple full-screen applications on your desktop.
"screen" will start the software and create a virtual terminal. CTRL+A C will create a new window, CTRL+A K will kill a window and CTRL+A D will detatch the window (essentially leaving screen). To enter screen you type "screen -r". In case you got more than one screen session you'll get a list with the ID and name of the session, and "screen -r ID" or "screen -r NAME" will enter that session.
3. How to use Minecraft and Screen.
The easiest way to run a Minecraft Server within Screen would be to run Screen and then start the server as usual, but we can do all of this using one line of code: "screen -dmS minecraft java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui". This will start screen in the background and name the session minecraft and then run the command. If you need superuser you can put "sudo" just before "java".
4. Creating a script to launch the server.
Everyone who use Linux is (or should be) lazy. You see, in Windows you have to do things yourself, but in Linux you have the ability to easily automate tasks. Open up nano and type the command you use to start your server ("screen -dmS minecraft java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui"), and save the file as "minecraft.sh". When you want to start the minecraft server you only have to type "sh minecraft.sh". Of cource you could spend more time and make it start on boot as well, but we'll leave it here for now.