Linux/Screen: Difference between revisions

From Dev Wiki
Jump to navigation Jump to search
(Create page)
 
m (Brodriguez moved page Linux Screen to Linux/Screen: Clean url with subpages)
 
(No difference)

Latest revision as of 08:53, 15 May 2020

Screen is a "terminal multiplexer". Essentially, it allows a user to access multiple, separate terminal sessions inside a single terminal window.
It's extremely useful for launching server applications on startup, allowing access to and interaction with the application later on.

Installation

Screen is automatically installed on most Ubuntu setups.
If screen is not already installed, then it can be installed with:

  • sudo apt install screen

Starting a Session

To start a basic session, run:

  • screen

To start a named session, run:

  • screen -S <session_name>

Using a Screen Session

From inside a session, hit ctrl + a to be able to adjust the session with the following commonly used args:

  • ? - Display list of possible screen commands.
  • c - Create a new virtual console session inside screen.
  • " - List all open virtual consoles.
  • n - Switch to next available virtual console.
  • p - Switch to previous virtual console.
  • <Number Keys 0 through 9> - Open the virtual console corresponding to the number.
  • A - Rename current virtual console.
  • d - Detach from screen session, bringing the standard terminal back up.
    • Current screen session will still continue the the background.
  • k - Kill current virtual console.
    • Ex: 0 will open virtual console 0.
  • <Esc Key> - Go back to standard terminal output in current virtual console.

Reattaching to an Existing Screen Session

Once detached from a screen session (using above d command), reattach with:

  • screen -r

If there are multiple screen sessions up, use the following to list them all:

  • screen -ls

The number at the start should be the session ID. Attach to the desired session ID with:

  • screen -r <session_ID>

Customizing Screen

When started, screen will read in values from /etc/screenrc and ~/.screenrc.
Open the associated files and adjust values as desired.