screen
Overview
The screen
command is a full-screen window manager that multiplexes a physical terminal between several processes. It allows you to run multiple terminal sessions inside a single terminal window.
Syntax
screen [options] [command [args]]
Common Options
Option | Description |
---|---|
-S name |
Set session name |
-r [pid] |
Reattach session |
-d |
Detach session |
-D |
Detach and logout |
-R |
Reattach if exists |
-x |
Attach to running |
-ls |
List sessions |
-L |
Enable logging |
-m |
Ignore $STY |
-c file |
Config file |
-v |
Version info |
Key Bindings
Command | Action |
---|---|
Ctrl-a c |
Create window |
Ctrl-a n |
Next window |
Ctrl-a p |
Previous window |
Ctrl-a d |
Detach session |
Ctrl-a k |
Kill window |
Ctrl-a ? |
Help screen |
Ctrl-a " |
Window list |
Ctrl-a A |
Rename window |
Ctrl-a S |
Split horizontal |
Ctrl-a | |
Split vertical |
Key Use Cases
- Session management
- Remote work
- Process monitoring
- Multiple terminals
- Long-running tasks
Examples with Explanations
Example 1: New Session
screen -S mysession
Create named session
Example 2: Reattach
screen -r mysession
Reattach to session
Example 3: List Sessions
screen -ls
Show running sessions
Common Usage Patterns
Start named:
screen -S name
Detach/reattach:
Ctrl-a d screen -r
Kill session:
screen -X -S [session] quit
Security Considerations
- Session access
- Multi-user mode
- Process isolation
- Log security
- Remote access
Additional Resources
Best Practices
- Name sessions
- Use logging
- Configure startup
- Monitor status
- Clean up
Configuration
- .screenrc file
- Key bindings
- Status line
- Window setup
- Logging options
Troubleshooting
- Session issues
- Permission problems
- Display errors
- Key binding conflicts
- Resource limits