Deepak Nadig Anantha

Recent Posts

Recent Comments




Using Screen to open multiple terminals from a single SSH session

Deepak Nadig AnanthaDeepak Nadig Anantha

Introduction to Screen

Screen is a linux application that can be used for creating multiple shell (bash) terminals from a single session. For example, if you have logged into a remote machine using ssh and would like access to multiple terminal windows, you can use screen to get the job done. So essentially, you can think of Screen as a window manager that will enable you to create multiple “Terminal Tabs” inside a single terminal session. So Screen acts as terminal emulator that multiplexes multiple terminal processes and each virtual terminal provides the same functionality of a regular terminal.

Installing Screen

You can check whether Screen is already installed on your machine by starting a terminal and running (without the $ symbol):

$ which screen

If it returns the following, then you are ready to use Screen.


If not, you can install it using the below command (assuming that you are running Ubuntu OS)

$ sudo apt-get install screen

Running Screen and Commands

To start screen, just open a terminal and type:

$ screen

Screen now automatically creates a window with a single virtual terminal, and you are now inside the virtual terminal. To control Screen behavior, you can use the command Ctrl-a. If you want check the available commands, you can use Ctrl-a and type ? to bring up the list of available commands.

List of Screen Commands

Screen Commands

Click on the blocks below to learn about some of the most commonly used commands in Screen:

Creating a New Screen
To create a new screen, you can use Ctrl-a and c. This will create a new screen and your old screens are still active.
Switching between Screens
To switch between screens, you can use Ctrl-a and n OR Ctrl-a and p to go to either the “next” or the “previous” screen. Once you reach the last screen, these commands cycle back again.
Logging information
To log all information in a screen session, you can use Ctrl-a and H. This will create a logfile by name screenlog.0 and logs your entire screen session output.
Detach/Re-attach Screen
This is a very powerful screen option that enables you to detach from a screen session, and re-attach later. To detach a screen session, use Ctrl-a and d, and to re-attach to a save screen session, use Ctrl-a and r. Once you detach from an existing screen session, it will drop you to your previous shell. You can then reattach to your screen session at any time, and you can retrieve all the previously created screens.
Lock your Screen(s)
Once you have created some screen sessions, you can also lock your current screen session using Ctrl-a and x.
Splitting Screens
You can have multiple screens visible at the same time using the screen split view. You can split screens horizontally using the command Ctrl-a and S, or vertically using Ctrl-a and |.
Split Screens

Split Screens

Have fun using Screen!

Comments 0
There are currently no comments.

%d bloggers like this: