You start a long database import over SSH, the wifi drops, and the import dies with the connection. Anyone who administers Linux remotely has done this at least once, and it is exactly the problem screen was built to solve.
What it gives you is a terminal that belongs to the server rather than to your connection. You can open several of them inside one SSH session, detach and walk away, then reattach later from a completely different machine and find everything still running. You can hand a session to a colleague to watch. And a job that takes six hours carries on whether or not you are still connected.
Installing Screen
Usually there is nothing to install. Screen ships with most systems, and on RHEL and CentOS it lands at /usr/bin/screen. The quickest way to confirm is to ask the shell where it is:
[root@linuxpathfinder ~]# which screen
/usr/bin/screen
Nothing back? Then it really is missing, which happens on minimal server images. Install it from the package manager:
[root@linuxpathfinder ~]# yum install screen
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
screen x86_64 4.0.3-16.el6 base 494 k
Transaction Summary
====================================================================================================
Install 1 Package(s)
Total download size: 494 k
Installed size: 795 k
Is this ok [y/N]: y
Downloading Packages:
screen-4.0.3-16.el6.x86_64.rpm | 494 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : screen-4.0.3-16.el6.x86_64 1/1
Verifying : screen-4.0.3-16.el6.x86_64 1/1
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!
Starting Screen Command
Starting it is as ordinary as it looks. Type the name and press enter:
[root@linuxpathfinder ~]# screen
The screen barely changes, which throws people the first time. You are now inside a screen window and it behaves exactly like the shell you just left. The difference isn’t visible. It’s that this shell now survives you disconnecting.
Everything screen does runs through one prefix key. Press “Ctrl-a“, let go, then press the key for whatever you want. Press “Ctrl-a” then “?” and it lists the lot, which is worth doing once early so you know what is available.
Creating Screen Windows
Press “Ctrl-a” then “c” and you get a fresh window. The old one doesn’t close or pause. It’s sitting there in the background, still running whatever you left in it.
That’s the whole idea. Kick off a build in one window, switch to another to tail a log while it runs, and both carry on independently. It’s roughly what tabs did for browsers, except these tabs live on the server.
Switching Windows
“Ctrl-a” then “n” moves you to the next window. Keep pressing it and you loop back round to the first one, so there’s no end of the list to fall off.
“p” goes the other way, to the previous window. Two keys, and that’s your entire navigation.
Whatever is running in a window keeps running whether you’re looking at it or not. Nothing pauses when you switch away, and nothing stops until you close that window.
Detaching From Screen
Detaching is the feature that earns screen its place. Press “Ctrl-a” then “d” and you drop back to your normal shell. The session doesn’t end. It carries on running on the server with every window intact, waiting for you to come back.
The obvious case is a large rsync between servers. Start it in a plain SSH session and you’re married to that connection for however long it takes. Start it inside screen, detach, and you can close the laptop. The transfer neither knows nor cares.
Anything long enough that losing it halfway would hurt belongs in a screen session. Copies, imports, compiles, upgrades. It costs one extra command at the start and saves the whole job.
Reattach Linux Screen
Coming back is one command, and it works the same whether you detached deliberately or the connection dropped on you.
[root@linuxpathfinder ~]# screen -r
That drops you straight back where you were, mid-job, as though nothing happened.
With more than one session running, screen won’t guess which you meant. It lists them instead:
[root@linuxpathfinder ~]# screen -r
There are several suitable screens on:
27458.pts-0.linuxpathfinder (Detached)
27447.pts-0.linuxpathfinder (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
You can also just ask what is running, without trying to attach to anything:
[root@linuxpathfinder ~]# screen -ls
There are screens on:
27832.pts-0.linuxpathfinder (Detached)
27899.pts-0.linuxpathfinder (Detached)
2 Sockets in /var/run/screen/S-root.
Then name the one you want. The number at the front is enough on its own, so there’s no need to type the whole string:
[root@linuxpathfinder ~]# screen -r 27458.pts-0.linuxpathfinder
Logging Screen Output
Sometimes you want a record of what you actually did. Change window, upgrade gone wrong, anything you might have to explain or repeat later.
Press “Ctrl-a” then “h” and screen starts writing the session to a file. A note appears bottom left to confirm it, and the file lands in your home directory as “screenlog.0”. Everything that scrolls past goes into it, so there’s no need to remember to copy anything out.
Same keys again to stop recording.
Getting Alerts on Screen
Screen can also watch a window and tell you when something happens in it. Useful when you are waiting on a long compile or a big download and would rather not keep flicking back to check.
Press “Ctrl-a” then “m” on the window you care about, then go and work somewhere else. When output appears, a notice shows up at the bottom of the screen.
Lock Screen Session
Stepping away from an unlocked terminal is a bad habit, and screen has an answer built in. Press “Ctrl-a” then “x” and it locks:
Screen used by root <root>.
Password:
Your normal Linux password unlocks it. Worth noting this locks the screen session rather than the machine, so it’s a courtesy against someone glancing at your terminal, not a substitute for locking the workstation.
Leave/Exit Screen
Two ways out, and the difference matters.
“Ctrl-a” then “d” detaches. The session stays alive on the server with everything still running, which is what you want almost every time.
“Ctrl-a” then “k” kills the window outright, as does typing exit. That ends whatever was in it. Only reach for this when you genuinely mean to stop the work, not just to close the terminal.
Screen does considerably more than this. Split panes, shared sessions, a config file for changing the prefix key if Ctrl-a clashes with something you use. Worth exploring once the basics are second nature.
Realistically though, most days come down to four things: start a session, “Ctrl-a” “c” for another window, “Ctrl-a” “d” to walk away, and screen -r to come back. Learn those and you stop losing work to dropped connections.

