Written by Alex Taylor | 11/13/2023

Using screen to tidy your terminal mess

Linux's screen is a terminal multiplexer, a smart tool for users who need to manage multiple sessions within a single terminal window. Here's why and how to use it effectively.

Why Use screen?

Using screen over multiple terminal windows has its perks:

  • Resource Efficiency: screen uses system resources more effectively by running multiple sessions within one terminal.
  • Persistence: Sessions in screen persist even when disconnected, allowing processes to continue running.
  • Convenience: Users can switch between sessions in screen without rearranging physical windows.
  • Organization: screen keeps all sessions in one place, reducing clutter and increasing manageability.


Basic Use of screen

  • Starting a new session: Type screen to begin a new session.
    screen
    Detach a session:

    Press Ctrl-a then d
    to detach from a session without ending it.
  • List sessions:
    screen -ls

    shows all active screen sessions.
  • Reattach to a session
  • screen -r session_name 
  • reconnects to an existing session.

Practical Examples

Long-running processes: Start a compile process in screen, detach, and come back later to check results.Multitasking: Use different screen windows for tasks like editing a script in one while another runs monitoring tasks.Remote Work: Launch a screen session on a remote server, work, detach, and later resume right where you left off.

screen is a powerful ally for keeping terminal work organized and under control, streamlining multitasking and terminal resource use.