Friday, September 27, 2024

Screen command

What is screen?

screen is a terminal multiplexer that allows you to manage several terminal sessions from a single window. This is particularly useful when you want to:

  • Run commands that take a long time to execute.
  • Disconnect and reconnect without interrupting your running processes.
  • Collaborate by sharing a terminal session with others.

With screen, you can detach from a session, log out, and reconnect later without losing your running applications. It’s like having multiple monitors in one terminal!

Basic Commands:

  • screen: Start a new session.

Common Flags:

  • -ls: List active screen sessions.
  • -aS screenname: Create a session with all capabilities.
  • -r: Resume a detached session.
  • -x: Attach to an active session.
  • -d: Detach from a session.
  • -d -m $command: Start a session in detached mode and run a command.
  • -DR: Force disconnect current user and reconnect with another.
-wipe: Remove dead screen sessions.

Common Screen Commands

  • List active sessions:
    screen -ls

  • Detach from a session:
    screen -d session_id

  • Reattach to a session:
    screen -r session_id

  • Detach and reattach to a session:
    screen -d -r session_id

  • Create a new session with a name:
    screen -S session_name

No comments:

Post a Comment