DevOps with Linux — Screen

Corrado Ignoti
3 min readMar 30, 2023
Photo by Jake Walker on Unsplash

If you are a senior (aka not-so-young) you probably know ‘screen’ but if you are younger you probably know ‘tmux’. Both are screen multiplexers and both are useful if, like me, your job, constantly asks you to use a terminal.

A closer look at screen

Screen is a terminal multiplexer for Linux that allows you to manage multiple terminal sessions within a single terminal window. It provides a way to run multiple terminal sessions within a single terminal window, which can be useful for running long-running processes, managing multiple connections to remote servers, or keeping terminal sessions open even after disconnecting from a remote system.

With screen, you can create new terminal sessions, switch between existing sessions, detach from a session and resume it later, and persist terminal sessions even after disconnecting from the terminal. Screen also provides basic window and pane management, allowing you to split a terminal window into multiple panes to run multiple processes at the same time.

Here are some basic commands to get started with screen:

  1. Start a new screen session: screen
  2. Detach from the current screen session: Ctrl-a d
  3. List available screen sessions: screen -ls
  4. Reattach to a screen session: screen -r [session_id]
  5. Create a new window within screen session: Ctrl-a c
  6. Switch between windows: Ctrl-a n (next) or Ctrl-a p (previous)
  7. Kill a window: Ctrl-a k
  8. Quit screen: Ctrl-a \ or exit

To put a process in the background using the screen utility, you can use the following steps:

  1. Start a new screen session: screen
  2. Start the process you want to run in the background: for example, ./long_running_process.sh
  3. Detach from the screen session: Ctrl-a d

The process will continue running in the background even if you log out from the terminal. You can later reattach to the screen session to check the status of the background process:

  1. List available screen sessions: screen -ls
  2. Reattach to the screen session with the background process: screen -r [session_id]

Quick and dirty screen e tmux comparison

Screen and tmux are both terminal multiplexers for Linux that allow users to manage multiple terminal sessions within a single terminal window. Here are some of the main differences between the two:

  1. User interface: Screen has a simpler user interface compared to tmux, which has more advanced features and customization options.
  2. Configuration: Screen uses a simple configuration file, while tmux has a more robust configuration system that allows users to customize the appearance and behavior of the multiplexer.
  3. Session management: Screen has basic session management features, while tmux has more advanced session management, including the ability to attach and detach sessions, switch between sessions, and persist sessions even after disconnecting.
  4. Window and pane management: Screen has limited window and pane management features, while tmux allows users to create and manage multiple windows and panes within a single session.
  5. Copy-and-paste: Screen has a basic copy-and-paste mechanism, while tmux provides a more advanced copy-and-paste interface, including the ability to scroll through previous output and select text with the mouse.

In summary, tmux is a more advanced and feature-rich terminal multiplexer compared to Screen, but it may have a steeper learning curve for new users.

--

--

Corrado Ignoti

Mobile enthusiastic with open source always in mind. Guitar player and music lover. With the head in the "cloud". Scout for the rest. He/him