Skip to content

Screen Command in Linux

The “screen” command in Linux is a terminal multiplexer, which allows a user to open and manage multiple terminal sessions within a single terminal window.

The primary benefit of using screen is that it allows users to maintain multiple terminal sessions within a single window, which can be useful in a variety of situations. Some common use cases for screen include:

  • Remote access: When working remotely, screen can be used to maintain a connection to a remote server even if the network connection is lost. This allows the user to reconnect to the server later and resume the session without losing any work.
  • Long-running processes: If a process is expected to run for a long time, screen can be used to detach from the session and reattach later, allowing the user to log out or switch to other tasks without interrupting the process.
  • Multiplexing: screen allows you to have multiple terminal windows open within a single screen session. You can switch between them easily, this can be useful when you are working on multiple tasks at the same time.
  • Collaboration: screen allows multiple users to connect to the same session, which can be useful for collaboration and troubleshooting.
  • Scripting: It can be used for running multiple commands in a script, and you can see the output of the commands in the screen.
  • Server Management: It can be used to manage multiple servers from a single terminal.

Some common commands for the screen include:

screen: Start a new screen session
screen -S session_name: To start a named session for better management
screen -ls: List all running screen sessions
screen -r: Resume a detached screen session
screen -d: Detach a screen session
screen -X: Send a command to a running screen session
screen --help: To check the help page of screen command
CTRL+a d: Detach from a screen session
CTRL+a c: Create a new terminal window within the screen session
CTRL+a n: Switch to the next terminal window within the screen session
CTRL+a p: Switch to the previous terminal window within the screen session
CTRL+a ": Show a list of all terminal windows within the screen session

You can also create a custom shortcut key to switch between the windows

CTRL+a a: Send the CTRL+a command to the current terminal window
CTRL+a ?: Show a list of the command-line options and key bindings.
Brijesh Gogia
Leave a Reply