Difference between revisions of "Screen - Virtual Terminals From Console"
m |
|||
Line 46: | Line 46: | ||
::: '''<nowiki>\</nowiki>''' kill all screen virtual consoles | ::: '''<nowiki>\</nowiki>''' kill all screen virtual consoles | ||
::: '''D''' Manually detach from session (same as disconnecting while screen is running) | ::: '''D''' Manually detach from session (same as disconnecting while screen is running) | ||
+ | ::: ''']''' Paste copied text from other session | ||
<big>'''Screen Sessions'''</big> | <big>'''Screen Sessions'''</big> | ||
Line 71: | Line 72: | ||
screen -D -RR | screen -D -RR | ||
* detach defunct client and attach current to first available session | * detach defunct client and attach current to first available session | ||
+ | |||
+ | <big>'''The Screen Scrollback Buffer'''</big> | ||
+ | |||
+ | * enter copy mode with Ctrl-A [ or via the copy command | ||
+ | * Arrow keys and Page Up/Down navigates. Vi nav also works. | ||
+ | * / and ? for vi-style search | ||
+ | * Ctrl-S and Ctrl-R for incremental search | ||
+ | * spacebar to mark text to copy and to mark copy end point | ||
+ | * Ctrl-A ] to paste copied text into other session | ||
+ | |||
+ | <big>'''screenrc'''</big> | ||
+ | |||
+ | When screen is invoked, it executes initialization commands from the files `.screenrc' in the user's home directory and `/usr/local/etc/screenrc'. These defaults can be overridden in the following ways: For the global screenrc file screen searches for the environment variable $SYSSCREENRC (this override feature may be disabled at compile-time). The user specific screenrc file is searched for in $SCREENRC, then `$HOME/.screenrc'. The command line option `-c' specifies which file to use. | ||
+ | |||
+ | The text scrollback buffer in screen is limited to 100 lines by default. Adding the following to the screenrc file will increase that to a reasonable amount: | ||
+ | |||
+ | defscrollback 1024 | ||
+ | |||
+ | |||
Revision as of 00:32, 25 January 2008
screen
screen [options] [command [args] ]
In their words: Provide ANSI/VT100 terminal emulation, making it possible to run multiple full-screen pseudo-terminals from one real terminal, and letting you manipulate and save your screen input and output, copy and paste between windows, etc.
In other words: multiple virtual terminals from one terminal (like a remote shell), with the ability to detach processes and leave them running even when you disconnect!
- Do more from one terminal connection
- Leave stuff running even if you detach or disconnect
- Handy for unreliable terminal connections
- Scroll back and see what you missed
Screen offers the ability to detach from a session and then attach to it at a later time. When detached from a session, the processes screen is managing continue to run. You can then re-attach to the session at a later time, and your terminals are still there, the way you left them.
Screen also maintains individual, searchable scrollback buffers for each of the windows it manages. Screen sends all entered text to the current window, with the exception of the command character. The default command character is Ctrl-A. .screenrc is the per-user configuration file in your home directory, and /etc/screenrc is the system-wide configuration file that applies to all users.
Screen sets TERM to screen—each screen window provides its own vt100-compatible virtual terminal. The variable WINDOW is set to the virtual window number, and the variable STY is set to your session name.
Using Screen Walk Through
1. Telnet or SSH into a remote Linux system with screen installed.
2. Type 'screen' in the shell and press enter.
3. CTRL-A + C will open a new screen virtual console.
- Say you had 'top' running in the first console, you can press CTRL-A and top will remain running in console 1, it will not be a stopped job, nor will it be 'background' it will in fact remain a fully interactive running process. It is just like you opened a second connection with the remote system.
4. CTRL-A + P will return you to the previous virtual console which is running the top command.
5. CTRL-A + N will put you into the second virtual console
- P for previous, N for next.
Basic Screen Commands
CTRL-A +
- N next console
- P previous console
- M monitor for activity
- _ monitor for inactivity (default 30 sec)
- " list of open screen consoles, use the J and K keys to navigate
- Shft A manually set screen names (label them)
- K kill a screen virtual console
- \ kill all screen virtual consoles
- D Manually detach from session (same as disconnecting while screen is running)
- ] Paste copied text from other session
Screen Sessions
This is the real beauty of screen. You are working within your virtual console, very busy, and your terminal session is lost, disconnected! With screen you can log back into the remote system and pick up where you left off!
Starting 'screen' without command line arguments starts a new screen session.
screen
After reconnecting to your shell, you can find and control existing sessions
screen -ls
- lists currently running sessions
screen -r sessionname
- attatch to a specific session by name
screen -x -r sessionname
- attatch to a specific session by name again allowing multiple attachments to a session
screen -R
- reattach if it can, or start a new session.
screen -D -RR
- detach defunct client and attach current to first available session
The Screen Scrollback Buffer
- enter copy mode with Ctrl-A [ or via the copy command
- Arrow keys and Page Up/Down navigates. Vi nav also works.
- / and ? for vi-style search
- Ctrl-S and Ctrl-R for incremental search
- spacebar to mark text to copy and to mark copy end point
- Ctrl-A ] to paste copied text into other session
screenrc
When screen is invoked, it executes initialization commands from the files `.screenrc' in the user's home directory and `/usr/local/etc/screenrc'. These defaults can be overridden in the following ways: For the global screenrc file screen searches for the environment variable $SYSSCREENRC (this override feature may be disabled at compile-time). The user specific screenrc file is searched for in $SCREENRC, then `$HOME/.screenrc'. The command line option `-c' specifies which file to use.
The text scrollback buffer in screen is limited to 100 lines by default. Adding the following to the screenrc file will increase that to a reasonable amount:
defscrollback 1024