Friday, July 20, 2018

Linux 1. Using Linux screen utility.

Screen is utility allowing you to open several terminal instances inside a single terminal window connection.

To install screen:
yum install screen -y

Using screen

  1. Opening new screen session: 
    1. Create screen with default name (screen will be named <pid>.<tty>.<host>):
      1. screen
    2. Create screen with custom name (<pid>.<custom-name>), i.e. wget-download. This gives ability to distinguish between present screens by name:
      1. screen -S wget-download
  2. To view all screen options:
    1. hit and release Ctrl+A and then hit ?
  3. To detach (disconnect) from current screen (you'll see "[detached from ..]" message):
    1. hit and release Ctrl+A and then hit d
  4. To list all available screens (number left to the ".pts" is screen id). (Detached) means nobody connected, (Attached) means that somebody is currently in that screen:
    1. screen -ls
  5. To reattach (reconnect) to the needed screen:
    1. By id:
      1. screen -r 12215
    2. By custom-name:
      1. screen -r wget-download
    3. Connect to already attached screen:
      1. screen -d -r 12215
  6. To lock current screen (password of the local user will be needed):
    1. hit and release Ctrl+A and then hit x
  7. To work with nested screen (screen id remains the same but you can switch between nested screens and prompt will show: screen 0 / screen 1 etc. when switching):
    1. To create nested screen:
      1. being inside screen hit and release Ctrl+A and then hit c
    2. To switch between nested screens:
      1. being inside screen hit and release Ctrl+A and then hit n (for next nested screen) or p (for previous nested screen)
    3. To list all nested screens:
      1. being inside screen hit and release Ctrl+A and then hit " (double quote - Shift+single quote)
  8. To "kill" screen:
    1. to terminate current screen type exit
    2. to terminate any screen using it's id (scree id is system pid): 
      1. kill pid

No comments:

Post a Comment