After another SSH login, `screen -r deploy` brings the named session into your current terminal. I’m intrigued that Screen can show different windows side by side in separate regions.
Compare the session with the terminal displaying it. Now inspect what remains running inside the session.
What Screen keeps running in a terminal
A Screen session holds virtual-terminal windows. Those windows can keep their programs running after you detach the session from its controlling terminal, then let you reconnect while the host and processes remain running.
A session, a window, and a region are different Screen objects. The session groups windows, and a region is a visible area that displays one window.
| Screen object | What it holds or displays |
|---|---|
| Session | A group of Screen windows that can be attached to or detached from a terminal. |
| Window | A virtual terminal running a shell or another command. |
| Region | An area of the display that shows a Screen window. Splitting creates regions, not windows. |
The view below shows Screen windows 0 and 1 in side-by-side regions.

Each region displays one of the two Screen windows, so both shells remain independent.
Install Screen on your Linux distribution
Install the screen package from your distribution’s configured repositories. Ubuntu uses apt, while Fedora provides the package through dnf.
| Distribution | Command | Package source |
|---|---|---|
| Ubuntu | sudo apt install screen | Ubuntu package details |
| Fedora | sudo dnf install screen | Fedora package details |
Fedora’s package page lists Screen in Fedora repositories, so Fedora does not need the EPEL setup shown in some Enterprise Linux instructions. If the command is missing after installation, check that your distribution’s repository configuration is enabled.
Start a named Screen session
Give a session a short name so you can identify it when reconnecting. This starts a new Screen session and opens its first shell window.
screen -S deploy
Run the command you want to keep inside that shell. Screen sends your keystrokes to the selected window, and the window remains available while the session is detached.
A long file transfer is one example, and our curl download tutorial shows that workflow.
- Start the session with a name such as deploy.
- Run the shell command inside the Screen window.
- Press Ctrl+A, then lowercase c, to open another window in the same session.
- Press Ctrl+A, then a double quote, to open the window list and select a window.
The window list shows each virtual terminal by number and title. Press Enter after selecting a row to switch to that window.

Screen assigns the highlighted row to the next window receiving input, and this example has window 1 selected.
A short title helps identify each shell, including when you keep a terminal editor in a separate window, as in our guide to terminal-based text editors for Linux. Press Ctrl+A, then uppercase A, to name the current window.

Type a short label at this prompt and press Enter, then verify the title in the window list.
Detach and reattach the same session
Press Ctrl+A, then lowercase d, to detach Screen and return to the shell that started it. The session and its windows stay available while the processes continue running on the host.

The detached message confirms that Screen left the session running. From the shell, list sessions and reattach by the name you chose.
screen -ls
screen -r deploy
I ran a shell command inside a named Screen session, detached it, and reattached to it. I saw screen -ls mark the session Detached before the next attachment.

The session name in the screenshot is an example, and the process identifier changes on each start. Look for the Detached label before running screen -r with that session’s name.
If a session is attached in another terminal, use the detach-and-reattach form only when you intend to move control away from that terminal.
screen -d -r deploy
Switch windows and split the display
Screen uses Ctrl+A as its default command prefix, followed by one key. The screen(1) manual documents the default bindings, and our guide to reading the Linux man command explains how to use manual pages.
| Task | Default keys |
|---|---|
| Open a new window | Ctrl+A, then lowercase c |
| Move to the next window | Ctrl+A, then lowercase n |
| Show the window list | Ctrl+A, then a double quote |
| Rename the current window | Ctrl+A, then uppercase A |
The Screen key-binding list shows the default commands for creating windows, detaching, renaming, and splitting. Your configuration can differ, so use the Screen manual as the reference.

Screen’s split keys change the display layout, then you choose what to show in each region.
- Press Ctrl+A, then the vertical bar, to create a side-by-side region.
- Press Ctrl+A, then Tab, to move focus into the new region.
- Press Ctrl+A, then lowercase c, to create a window, or open the window list to select one.
- Press Ctrl+A, then uppercase S, to create a top-and-bottom split.
A new region starts blank until you select or create a Screen window for it.

Press Ctrl+A, then Tab, to move focus to the blank region. Open a new window there or select an existing one from the window list.
Windows 0 and 1 remain separate shells in the side-by-side display shown above.
Ctrl+A, then uppercase S, splits the display into stacked regions. The layout below combines a vertical split with a horizontal split to show three windows at once.

Screen can show several regions, though the manual warns that scrolling output can appear much slower in a vertically split region. Keep a full-width window for output that you need to scan quickly.
Find the right session when reattach fails
An attached session still has a controlling terminal, while a detached session can be reattached from another terminal.

The listing shows an Attached session beside a Detached one, so choose the intended name or identifier before reattaching.
| What screen -ls shows | Next action |
|---|---|
| No sockets found | There is no Screen session for this account on this host. Start a new named session. |
| Several detached sessions | Use screen -r followed by the exact session name or identifier. |
| The target session is Attached elsewhere | Use screen -d -r with its name only if you intend to disconnect the other terminal. |
| A session is marked Dead or Unreachable | Check its host and process state before removing a stale socket. |
The -d option disconnects the other terminal before attaching here. That moves the terminal connection, but the shell and processes inside the Screen session keep running while the host remains available.
I ran screen -d -r with that session attached elsewhere, and the shell command stayed available after the terminal connection moved.
If a job should run as a managed service after logout, use our guide to starting and stopping Linux services.
Close the session after its work is done
Exiting the shell closes its Screen window. If the session has multiple windows, close each window you no longer need or send Screen a quit command for the named session.
screen -S deploy -X quit
This command ends the named Screen session and its windows, so check that no command still needs to run before using it. A Screen session also ends when the host restarts, as explained in our guide to restarting Linux from the terminal.

Use screen -ls again to confirm that a named session has closed. A detached session remains available, and a quit command ends the session and the work still running in its windows.
Screen command questions
The FAQ below covers the session questions that are not answered by the command sequences above.
Will Screen keep running after an SSH disconnect?
A detached Screen session can keep its windows and processes running after the SSH terminal disconnects, as long as the host and the processes remain running. Screen does not protect a process from a host shutdown or process failure.
How do I reattach to a named Screen session?
Run screen -r followed by the session name, such as screen -r deploy. Use screen -ls first if you need to find the name or identifier.
How do I detach from Screen without stopping a command?
Press Ctrl+A, then lowercase d. Screen returns you to the shell while keeping the session detached.
How do I close a Screen session?
Exit each shell you want to close, or run screen -S followed by the session name and -X quit. The quit command ends the session and its windows.
