Using screen with Linux and Half-Life Counter-Strike
This document explains why and how to use screen to run your Half-Life Counter-Strike
server under Linux.
What is screen?
Screen is an application that is part of the default distribution of many types
of Linux. It allows you to create virtual terminal screens which can be detached
and run in the background, then re-attached and brought to the foreground at
will. In MS-Windows terms, think of it like minimizing a window. It's still
there and running, you just aren't looking at it on your desktop. Screen does
the same thing for terminals like Xterm, telnet or ssh.
Do I have screen?
To find out if screen is installed on your system, go to a command terminal
and type in "which screen". If it comes back with something similar
to "/usr/bin/screen", you're in business. If instead it comes back
with something similar to "which: no screen in /usr/bin:/bin:/usr/bin...",
screen is not installed. You should stop reading this now while you figure out
where to get and install it from. A good place to look is http://www.rpmfind.net.
Is screen the best method?
No, but it is a good place to start before you get into something more complicated.
The first method most people learn is running a process in the foreground, like:
This will run the server just fine. Just don't close that terminal
window or your server goes along with it into oblivion. Then you might ask around
and learn that adding a "&" will launch the server into the background,
like:
This is even better. It launches your server and runs it in the
background. Now you can close the terminal window and the server still runs.
Unfortunately you can't get back to your server console and can only administer
your server with RCON or something like Alfred's Admin Mod.
So how do I use it?
Get into a text terminal. Then type in the following command, which will create
a virtual terminal, start your Half-Life Counter-Strike server, and return to
your regular terminal:
You may wish to customize this your command line. The Counter-Strike
Command Line editor is a great tool for figuring out how your command line should
look. Just add "screen -A -m -d -S hlds " in front of whatever command
line you choose.
Once you have executed the command to start screen and your CS
server, type in:
screen -r hlds
This tells screen that you wish to attach to the virtual terminal
you already created. The next thing you should see is your CS server's console.
If you want to detach from the virtual terminal, or in other words leave the
CS server running in the background, hit your "Ctrl" and "a"
keys simultaneously, then hit your "d" key.
What else can I do?
Go ahead and attach to your virtual terminal with the "screen -r hlds"
command. Once there, hit your "Ctrl" and "a" keys simultaneously,
and then hit your "ESC" key. Using the up and down arrow keys you
can now scroll through your server's console, past what would normally be visible.
When you are done, hit the "ESC" key again.
Doing "man screen" from your terminal prompt will give
you more information about screen and how to use it.
You said screen wasn't the best way. What is?
A couple of very useful tools for Linux administrators are hlmonitor and hlds_ld.
I highly recommend you check them both out and choose what fits you best. Screen
is good, but these are far better.