> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.deluxhost.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Screen

## What is Screen

`Screen` is a tool found only on **Linux** and highly useful for server configuration and management by a **team**. It allows users to create, manage, and detach **terminal sessions,** which can continue running in the background even if the connection to the server is interrupted. Below is a guide for proper use.

### Installation

On most Linux distributions, `screen` comes preinstalled. If not, you can install it with:

```bash Service Installation theme={null}
sudo apt-get install screen  # for Debian/Ubuntu
sudo yum install screen      # for CentOS/RHEL
```

### Usage

**1.** **Create a new screen session**

```bash theme={null}
screen -S name
```

**2**. **Basic commands:**

1. To **detach** a screen, use the combination keys of `CTRL` + `A` + `D`

2. To **reattach** it, type: `screen -r name `

3. To see all **active sessions**, type:`screen -ls`

**3. Advanced Commands**

1. **Move** between screens: `Ctrl + A` then `N` (next) or `P` (previous)

2. **Close** the current screen: Type `exit`

3. **Switch** to a specific screen within a session: `Ctrl + A` followed by the window number, e.g., `Ctrl + A 0`

**4.** **Session Management**

* Save the session output:

```
screen -L
```

* Reattach a specific detached session:

```
screen -r session_name
```

* &#x20;Terminate a specific session:

```
screen -X -S session_name quit
```

<Note>
  To forcefully stop a screen, use `screen -X -S session_name kill`
</Note>

**5. Forced stop commands**

* End the session using the PID:

1. Get the **PID** of the session from the screen list, via `screen -ls`

2. Then, type:&#x20;

```bash theme={null}
kill -9 PID
```

<Warning>
  **Waning:** `kill -9` is a forced close, so the screen will close immediately, whatever its state (useful in case of a crash), but nothing will be saved upon closing
</Warning>

* Kill all sessions forcefully:

```bash theme={null}
killall screen
```

> **When to use `killall screen`:** This command should be used as a **last resort,** as it will terminate all active and detached screen sessions for **all** users on the system. It’s best used when screens are **unresponsive** or left open by mistake, especially if you have administrative rights and need to close lingering sessions.

<Warning>
  **Warning**: Use forced shutdown commands with caution. Terminating screen sessions abruptly may cause data loss, interrupt applications, or corrupt files, especially if critical processes are running. Always try `quit` first to allow programs to exit gracefully, and reserve forced termination for unresponsive sessions only.
</Warning>
