GNU Screen In Linux

Overview

Screen is a handy terminal application which runs on top of Linux terminal itself. This means allows you to create sessions with in a terminal and each session are self contained.

A feature that I use of screen is the detachable feature. Each screen session is attachable. Once it has been detached you return to your original shell and can exit / logout but the screen session would still be running as long as the computer itself is still running. You can log back on later and reattach to the screen session and continue from where you left of. This gives you the ability to run long intensive tasks, detach the session and come back to it later when it has finished.

Basics

In Ubuntu you have to install screen first:
sudo apt-get install screen

When GNU screen is started it loads a fresh terminal. To do screen commands it is usually these keyboard key combinations:
ctrl+a
Followed by a key or typing a command.

To start screen:
screen

It is always advisable to name your sessions with a name. This can be done with the -t argument. For example
screen -t formatUSB

The screen session can also be named within the session itself:
ctrl+a
:sessionname formatUSB

To “detach” a screen and come back to it later use:
ctrl+a d
This will through you back to your original terminal before you started screen. What ever you left running in Screen is still running in the background.

To get back into your Screen terminal use the command screen -r If you only have 1 screen running it will attach that Screen. However if you have multiple Screens you can list the screens running using the argument -ls e.g screen -ls This is where naming your screen sessions comes in handy otherwise they are just a process number and a few other Linux environment variable thrown into the name. Using the normal attach arugment but parse it the name to reattach to a specific screen e.g screen -r formatUSB

Split Screen

Here’s a cool way of splitting the terminal in Linux using Screen. It allows you to have a two terminals open at the same time and displayed at the same time with the ability to tab between them. It is possible to split them up multiple times but I have found two was enough.

Horizontal Split Screen

For a horizontal split do the following keyboard shortcuts:
ctrl+a shift+s
Split the screem
ctrl+a tab
Tab to the lower screen
ctrl+a c
Create a new screen

Use ctrl+a tab to switch between the upper and lower screens. Each screen can be further split by doing the same combinations again. The key combination seems odd because I associate ctrl+a as select all.

Vertical & horizontal split for man screen Article from CodeSnippets

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Linux, Software and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *.

All comments must go through an approval and anti-spam process before appearing on the website. Please be patience and do not re-submit your comment if it does not appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.