Linux command
screen 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start a new screen session
screen
Start a named session
screen -S [session_name]
List active sessions
screen -ls
Reattach to a session
screen -r [session_name]
Detach from current session
Ctrl+a d
Create a new window
Ctrl+a c
Split screen horizontally
Ctrl+a S
Kill current window
Ctrl+a k
说明
screen is a terminal multiplexer that allows running multiple terminal sessions within a single window. Sessions can be detached and reattached, making them persistent across disconnections—essential for remote work and long-running processes. Each screen session can contain multiple windows, each running its own shell or program. Windows can be split into regions to view multiple windows simultaneously. Sessions persist even when you disconnect, whether intentionally or due to network issues. This makes screen invaluable for running processes on remote servers that must survive connection drops. Copy mode allows scrolling through terminal history and copying text between windows or to the clipboard.
参数
- -S _name_
- Create session with specified name
- -r _name_
- Reattach to a detached session
- -R
- Reattach if possible, otherwise start new session
- -d
- Detach a running session
- -D
- Detach and logout
- -ls, -list
- List all sessions
- -x
- Attach to a session that is already attached (multi-display)
- -dm
- Start in detached mode (for scripts)
- -X _command_
- Send command to a running session
- -L
- Enable logging
- -h _lines_
- Set scrollback buffer size
FAQ
What is the screen command used for?
screen is a terminal multiplexer that allows running multiple terminal sessions within a single window. Sessions can be detached and reattached, making them persistent across disconnections—essential for remote work and long-running processes. Each screen session can contain multiple windows, each running its own shell or program. Windows can be split into regions to view multiple windows simultaneously. Sessions persist even when you disconnect, whether intentionally or due to network issues. This makes screen invaluable for running processes on remote servers that must survive connection drops. Copy mode allows scrolling through terminal history and copying text between windows or to the clipboard.
How do I run a basic screen example?
Run `screen` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -S _name_ do in screen?
Create session with specified name