Ever wanted to run a long-running command but you can’t seem to get it to complete because you have a shaky connection? Can’t run your command in the background? Want to leave your IRC session open so you can SSH from work and catch the chat room action? Enter screen. Screen allows you to
Well, installation depends on your flavor of Linux. Here are the installation methods for a few common flavors of Linux:
To install screen with up2date issue this command:
# up2date -i screen
To install screen with yum issue this command:
# yum -y install screen
To install screen with apt issue this command:
# apt-get install screen
Using screen is extremely easy. Here are a few commands to help you understand how it operates.
Creating a new screen
Type "screen" to start a new screen. Note that the title of putty (if you’re using putty) tells you which screen you are currently attached to by inserting "[screen 0: bash] before your normal [email protected]:/path text.
You should now run any commands you want to save inside your "screen".
Detaching a screen
To detach your current screen simply press "CTRL + AD" (Control plus A then D). You are now presented with a message saying "[detached]". You are now returned to your normal shell outside of your virtual screen.
Attaching to an existing screen
Chances are if you are using screen you’ll need to reattach to your detached screen. Type "screen -r" to reattach to your current screen. If multiple screen sessions are active, you’ll see a list of current screens to choose from. Type "screen -r PID" to reattach to that screen.
Multiple screens to choose from
Here’s a quick demonstration of screen.