Techmania

September 16, 2011

Multiple Terminals in the same Session with Screen

Filed under: Development,FOSS,Linux — mifan @ 8:30 am

As an administrator or unix user who has just SSH’d into a remote server, have you had the requirement to open multiple remote terminals without having to resort to re-logging in multiple times? I’ve had this one too many times, where I needed to run multiple apps, view logs etc. etc. in separate terminals, which can be made easy using GNU Screen.
GNU Screen is a screen multiplexer, which can be installed via a simple apt-get install screen on your linux server. This should be available by default as well. Once that is done, the following steps should suffice

  • Login to your remote terminal (e.g: via SSH)
  • Open Screen
 user@remote> screen
  • Use the following commands to create, navigate etc. CTRL+A (CTRL A) is the control key in my Ubuntu server by default, and this might be the case for you as well. Thus when I refer to CTRL A p, I mean holding CTRL + A down, press the ‘p’ key
  • Create a new terminal:
user@remote> CTRL A c
  • Move to the next terminal:
user@remote> CTRL A n
  • Move to the previous terminal:
user@remote> CTRL A p

Etc. Some more commands are as follows

  • Move to a specific terminal: CTRL A “
  • Move to the last used terminal: CTRL A A
  • Move to terminal number 0 (0-9) : CTRL A 0

These commands were enough to get me going. For even further commands and to explore the power of screen in depth, here are some useful resources:

Resource 1, Resource 2

Blog at WordPress.com.