Skip to content

Screen - independent terminal session

To work with long running scripts nohup may be used. But to have better and further control screen will help. It also allows to share the terminal session.

Installation

$ sudo pacman -S screen
$ sudo apt update
$ sudo apt install screen

Start screen

Start a new session:

$ screen      # new default session
$ screen -S my_name # named session

Named sessions are useful when you run multiple screen sessions.

Working in screen

Within the screen the following commands will help:

  • Ctrl+A and ? Show all commands
  • Ctrl+A and D will detach from screen and you may close the terminal

Scrolling in output buffer can be done using:

  • Ctrl+A and Esc to switch mode
  • then Up and Down to navigate
  • and Esc to end this mode

Windows

When you start a new screen session, it creates a single window with a shell in it. But multiple windows inside a Screen are possible (with numbers 0..9).

  • Ctrl+A and C Create a new window (with shell)
  • Ctrl+A and " List all window
  • Ctrl+A and Space Switch between windows
  • Ctrl+A and N Switch to next window
  • Ctrl+A and P Switch to previous window
  • Ctrl+A and 0...9 Switch to window by number
  • Ctrl+A and A Rename the current window
  • Ctrl+A and S Split current region horizontally into two regions
  • Ctrl+A and | Split current region vertically into two regions
  • Ctrl+A and Tab Switch the input focus to the next region
  • Ctrl+A and Ctrl+A Toggle between the current and previous region
  • Ctrl+A and K Close the current window
  • Ctrl+A and Q Close all regions but the current one
  • Ctrl+A and X Close the current region

Resume screen

And to jump into a running screen use:

$ screen -r   # reattach to default session
$ screen -ls  # show list of screens with numbers
$ screen -r <num> # reattach to numbered entry

Delete screen

From the outside a screen can be deleted using:

$ screen -d <num>