Home > COTD (Command Of The Day) > COTD: Screen

COTD: Screen

Overview

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

 

Installation

Well, installation depends on your flavor of Linux. Here are the installation methods for a few common flavors of Linux:

 

up2date

To install screen with up2date issue this command:

# up2date -i screen

 

yum

To install screen with yum issue this command:

# yum -y install screen

 

apt

To install screen with apt issue this command:

# apt-get install screen

 

Usage

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 user@host:/path text.
image

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.
image
Multiple screens to choose from

Video Overview

Here’s a quick demonstration of screen.

Categories: COTD (Command Of The Day) Tags:
  1. No comments yet.
  1. No trackbacks yet.