Screen is terminal multiplexer. More simply, using Screen, you can have multiple terminal sessions running within a singular window. Each pane is running its own independent terminal session. Screen enables for long running sessions that won't disconnect!

Before getting into how to use screen, it is important to note all commands in Screen are trigged by a prefix key followed by a command. The Screen prefix key is C-a
The C- notation means press and hold the Ctrl key. 

Together C-a means to press the Ctrl & a keys at the same time.

  • Install Screen on a Personal Machine

    Linux

    Use the following Terminal command to install Screen (depending on your Linux OS):

    sudo apt-get install screen
    sudo yum install screen
    sudo dnf -y install screen

    macOS

    Use the following Terminal command to install Screen:

    brew install screen
  • Navigating Screen Windows

    Launch Screen (Start a Session)

    To launch Screen, open your terminal window and execute the following command:

    screen

    Create a Named Window

    You can create a named Screen Window/session with the following command (where sessionname is descriptive title for your session):

    screen -S sessionname

    Navigate Screen Windows

    Screen allows you to create multiple windows, similar to having multiple virtual desktops.

    Create Additional Windows

    Once within Screen, you can create additional windows at any time:

    prefix + c

    Change Screen Windows

    To navigate through your Screen windows:

    prefix + Ctrl+a

    With this command, execute the Screen prefix two times!

  • Session Handling with Screen

    One of the perks of using Screen is its ability to maintain sessions in the background. If you are done with your work for the day, you can keep the session alive in the background for later use. 

    Detach Sessions

    Use the detach command to detach your current session so you can shutdown:

    Detach All Windows

    prefix + d

    Restart Detached Sessions

    To view a list of the Screen sessions running in the background:

    screen -ls

    You can resume the specific session with (where sessionnumber is the beginning number of the session information):

    screen -r sessionnumber
    Resuming Screen code - viewing all open sessions and code to resume the 291 session.