• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

A cPanel Tech

The Diaries of a Linux Server Administrator

  • Home
  • About
  • Privacy
You are here: Home / Tutorials / How to Keep Your Shell Session Alive Using “Screen”

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/cptech/public_html/wp-content/themes/genesis/lib/functions/image.php on line 116

How to Keep Your Shell Session Alive Using “Screen”

August 2, 2013 By admin Leave a Comment

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).  There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.

When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any  time, you can create new (full-screen) windows with other programs in them (including more shells), kill existing windows, view a list of windows, turn output logging on and off, copy-and-paste text between windows, view the scrollback history, switch between windows in whatever manner you wish, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user’s terminal. When a program terminates, screen (per default) kills the window that con‐tained it. If this window was in the foreground, the display switches to the previous window; if none are left, screen exits.

In simple words, screen is a tool that will help us to maintain multiple sessions of ssh without disturbing each other.

Installation

On CentOS Linux, you can install “screen” using Yum:

yum install screen

On Ubuntu-based servers, use “apt-get” to install “screen”:

sudo apt-get install screen

Starting a Screen

You can start with ” screen ”

Or you can name it with:

screen -S SCREEN_NAME

Now you will be in that session, run your commands, and then close the terminal. When you are back open the terminal and run:

screen -ls

it will list all the active screen sessions and you can choose to which one you need to login to using this command:

screen -x SCREEN_NAME

Screen is an ideal tool when you have a choky internet connection of you are doing a task which is going to take long and you need to travel in between or if you have a screen session, it is easy to escalate issues or you can just port the ssh session to some one else who need to work on the task.

Filed Under: Tutorials Tagged With: linux, screen, shell session

Reader Interactions

Leave a Reply Cancel reply

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

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

Primary Sidebar

Copyright 2018 CPanelTech