[How-To] Use "screen" on your Linux Minecraft Server
So you've got your new hosted server or you're running Linux on a spare machine.. awesome! Linux is a great OS and really fun to learn given that you have the patience for it. So you're either using the Terminal or you've logged into your server using PuTTy and you keep running into a little problem... your server quits every time you close the terminal or PuTTy!
Well thankfully there's an easy fix to this.. it's a nifty little program called "screen". What screen does is essentially give you a second terminal "window" in which you can execute commands and start applications within. If you've ever wondered how to close your Terminal/PuTTY window/connection and keep your server running, this is it! So let's get started.
[Step 1] Installing Screen
Depending on your version of Linux (Ubuntu, Debian, CentOS, etc) installing screen relies on a package manager/installer. You'll either use "apt" or "yum". If you know which one your distro uses, choose that command from the following. If you don't, you're free to try both, it wont hurt anything and only one will work.
Login to your server as "root" if available, if you do not have root access to your server then this may not work and you'll have to ask your host to provide you with instructions. If you are logged in as a username other than root you can always prefix any of these commands with "sudo" or "su".
apt-get install screen (hit enter)
yum install screen (hit enter)
[Step 2] Using Screen
Once the installation is finished, you're ready to use screen. Using screen is just as easy as installing it.. all you have to do is type one command.
screen (hit enter)
Now you should see a fresh terminal screen and you're ready to perform your commands to start your server. Once you've got your Minecraft server running and you see the games console on your screen, you're done! Now there are just a couple extra commands to remember to control your new toy.
Exiting (detaching) from your Minecraft console's screen
So you've started your server and you're staring at the console, ready to exit and work on something else or play the game?
To detach the screen you're currently viewing you'll do this:
hold down CONTROL and hit A and then D
You should now see (detached) and your original Terminal/PuTTy screen.. congrats, you're almost done!
Resuming a running screen
So you've detached your screen, your server is still running and you've closed PuTTy/Terminal and played the game for a couple hours.. but you need to restart your server.. how? Log back into your server and type:
If you only have one screen running, you'll be instantly transferred to that one screen. If you happen to have opened more than one in your travels, you'll be presented with a list of open screens that looks similar to this:
There are several suitable screens on:
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
If you're presented with this list, you'll want to use the "PID" number at the beginning of the screen you want to resume, in the above examples the PIDs are 6962 and 6966. To resume one of the screens you'd use the following format:
screen -r 6962
If you have any questions, feel free to ask but I've covered just about everything here so good luck and enjoy your new found knowledge. :smile.gif: