Detach screen

To start screen just type screen and then you'll be in your new terminal. When ready to detach, hit CTRL+a and d.


Reattach screen

  • If only one screen is open:
    screen -R
  • If more than one screen is open:
    screen -list ( get the terminal_id )
    screen -R terminal_id ( reattach the screen )

Recover from a disconnected session

If the connection lost when in a screen session, then when you try to connect to that screen session you get the message: There is no screen to be resumed.

To recover the session, use the following command:

screen -d -r 29721.pts-6.bugs

(where 29721.pts-6.bug is the screen session name)


Windows management

  • Create a new window: CTRL+a c
  • Kill the current window: CTRL+a k
  • Kill all windows: CTRL+a \
  • Switch to the next window: CTRL+a n
  • Switch to the previous window: CTRL+a p
  • List available windows: CTRL+a "
  • Start/stop logging the current window to 'screenlog.X': CTRL+a H

Region management

  • Split the current region: CTRL+a S
  • Kill the current region: CTRL+a X
  • Switch the focus to the next region: CTRL+a TAB
  • Delete all regions but current one: CTRL+a Q

Scrollback buffer

  • To configure, add the following in $HOME/.screenrc:
    defscrollback N (where N is the number of lines)
  • To enter scrollback mode: CTRL+a [
  • To exit from scrollback mode: Esc
  • To navigate, use VI navigation keys, like h, j, k, G, etc
  • To search text in scrollback buffer: / (search forward) or ? (search backward)