gnu screen
play

GNU Screen Matt G. Habib & Ryan Curtin LUG@GT Matt G. Habib - PowerPoint PPT Presentation

GNU Screen Matt G. Habib & Ryan Curtin LUG@GT Matt G. Habib & Ryan Curtin GNU Screen - p. 1/26 Introduction What is GNU Screen and why should I care? Introduction Basic Screen Terminal multiplexer screenrc File


  1. GNU Screen Matt G. Habib & Ryan Curtin LUG@GT Matt G. Habib & Ryan Curtin GNU Screen - p. 1/26

  2. Introduction What is GNU Screen and why should I care? » Introduction Basic Screen � Terminal multiplexer screenrc File � Preservation of sessions/jobs Advanced Screen � Access to the same job from multiple places Crazy Screen � Multiple-user shared sessions (group collaboration) Questions � Quick task switching Matt G. Habib & Ryan Curtin GNU Screen - p. 2/26

  3. Quick Demonstration To start a session, just type screen . Your .screenrc file will » Introduction Basic Screen be read. » Quick Demonstration » Screen Modes » Comandline Parameters » Default Key Bindings (1/2) » Default Key Bindings (2/2) screenrc File Advanced Screen Crazy Screen Questions Matt G. Habib & Ryan Curtin GNU Screen - p. 3/26

  4. Screen Modes A screen session can be in one of five different modes. These » Introduction modes can be run by typing the command screen -ls . The Basic Screen » Quick Demonstration following table lists the various modes a screen session can » Screen Modes » Comandline Parameters exist in. » Default Key Bindings (1/2) » Default Key Bindings (2/2) Mode Description screenrc File attached session is running and has a controlling Advanced Screen terminal Crazy Screen Questions detached session can be reattached using -r option multi session is in multiuser mode unreachable* either live on a different host or ‘dead’ dead should be throughly checked and removed using -wipe option * An unreachable session is considered dead when its name matches either the name of the localhost or the specified parameter, if any. Matt G. Habib & Ryan Curtin GNU Screen - p. 4/26

  5. Comandline Parameters The following table lists a few commonly used options when » Introduction running screen: Basic Screen » Quick Demonstration » Screen Modes Option Description » Comandline Parameters » Default Key Bindings (1/2) » Default Key Bindings (2/2) -ls Prints a list of all screen sessions (previous screenrc File slide) Advanced Screen -A Adapt the size of all windows to the size of the Crazy Screen current terminal Questions -R Reattach a session and if necessary detach it first or even create it first -x Attach to a not detached screen session Matt G. Habib & Ryan Curtin GNU Screen - p. 5/26

  6. Default Key Bindings (1/2) Without these general key bindings, you will surely be lost! » Introduction Basic Screen » Quick Demonstration Command Description » Screen Modes » Comandline Parameters C-a ’ Prompt for a window name to switch to » Default Key Bindings (1/2) » Default Key Bindings (2/2) C-a " Present a list of all windows for selection screenrc File C-a 0 ... C-a 9 Switch to window number 0-9 Advanced Screen C-a tab Switch the focus to the next region Crazy Screen C-a C-a Toggle to the previously displayed window Questions C-a A Title the current window C-a c Create a new window with a shall C-a d Detach screen from the current terminal C-a F Resize the window to the current region size C-a H Begins/ends logging of the current window Matt G. Habib & Ryan Curtin GNU Screen - p. 6/26

  7. Default Key Bindings (2/2) » Introduction Command Description Basic Screen » Quick Demonstration C-a k Destroy the current window » Screen Modes » Comandline Parameters C-a m Repeats the last message displayed in the win- » Default Key Bindings (1/2) » Default Key Bindings (2/2) dow screenrc File C-a M Toggles monitoring of the current window Advanced Screen C-a C-g Toggles the visual bell Crazy Screen C-a n (p) Switch to the next (or previous) window Questions C-a S Horizontaolly splits the current region C-a x Lock the terminal C-a X Remove the current region (split screen) C-a esc Enter copy/scrollback mode C-a * Show a listing of all currently attached displays The default key bindings can be customized in the screenrc file. Matt G. Habib & Ryan Curtin GNU Screen - p. 7/26

  8. Custom Keybindings You can define your own keybindings and actions to go with » Introduction them. Basic Screen screenrc File bind [-c class] key [command [args]] » Custom Keybindings » More Custom Keybindings bindkey [input sequence] [command [args]] » Other Useful screenrc Commands command -c [class] » Starting default screens Advanced Screen For instance, map C-f 1 to switch to window 11: Crazy Screen bindkey "ˆF" command -c switch10 Questions bind -c switch10 1 select 11 Matt G. Habib & Ryan Curtin GNU Screen - p. 8/26

  9. More Custom Keybindings Make ’C-Y’ start a window watching syslog: » Introduction bind ˆY screen -t log watch -n 5 rail -40 Basic Screen /var/log/syslog screenrc File » Custom Keybindings » More Custom Keybindings F8 to turn the status bar on: » Other Useful screenrc Commands bindkey -k k8 hardstatus alwayslastline » Starting default screens Advanced Screen F9 to turn the status bar off: Crazy Screen bindkey -k k9 hardstatus alwaysignore Questions Matt G. Habib & Ryan Curtin GNU Screen - p. 9/26

  10. Other Useful screenrc Commands defscrollback [num] - define length of scrollback buffer » Introduction Basic Screen startup_message off - you don’t want it on screenrc File » Custom Keybindings vbell on - if you hate yourself » More Custom Keybindings » Other Useful screenrc Commands vbell_msg [message] - display message at the bottom for » Starting default screens a bell alert Advanced Screen Crazy Screen nethack on - slightly entertaining messages Questions msgwait [seconds] - set message timeout Matt G. Habib & Ryan Curtin GNU Screen - p. 10/26

  11. Starting default screens In your screenrc, use the screen command: » Introduction Basic Screen screen [-n #] [-t title] [-L] [-M] [command screenrc File [args]] » Custom Keybindings » More Custom Keybindings » Other Useful screenrc -L - enable logging Commands » Starting default screens -M - enable monitoring Advanced Screen Example: Crazy Screen screen -t "yes sir" yes Questions screen -n 5 -t "python shell" python Matt G. Habib & Ryan Curtin GNU Screen - p. 11/26

  12. Password Protection Prevents malicious users from baggy-pantsing your beautiful » Introduction screen session. Basic Screen screenrc File Generate hash: Advanced Screen C-a :password » Password Protection » Copy/Paste Password is placed in copy buffer ( C-a ] ) » Logging » Hardstatus Line » Hardstatus Line String (1/2) Now place hashed password in screenrc: » Hardstatus Line String (2/2) password [HASH] » Backtick » Horizontal Screen Split Crazy Screen Questions Matt G. Habib & Ryan Curtin GNU Screen - p. 12/26

  13. Copy/Paste C-a Esc - Enter copy mode » Introduction Basic Screen When in copy mode, Y grabs the current line and exits copy screenrc File mode. y starts marking from the beginning of the line. W marks Advanced Screen exactly one word and exits copy mode. » Password Protection » Copy/Paste » Logging C-a [ - Copy selected text into copy buffer » Hardstatus Line » Hardstatus Line String (1/2) C-a ] - Paste text in copy buffer » Hardstatus Line String (2/2) » Backtick In copy mode, / searches forward, ? searches backwards » Horizontal Screen Split (vi-style). Crazy Screen Questions Matt G. Habib & Ryan Curtin GNU Screen - p. 13/26

  14. Logging Dump current screen to file (“screen capture”): » Introduction C-a h dumps to hardcopy.n in the default directory. Basic Screen :hardcopy filename dumps to filename screenrc File Advanced Screen Log screen to file: » Password Protection » Copy/Paste C-a H logs to screenlog.n (unless logfile is defined) in default » Logging » Hardstatus Line directory. » Hardstatus Line String (1/2) » Hardstatus Line String (2/2) :logfile filename defines the file to log to. » Backtick » Horizontal Screen Split Hit C-a H again to stop logging. Crazy Screen Questions Matt G. Habib & Ryan Curtin GNU Screen - p. 14/26

  15. Hardstatus Line hardstatus [on|off] » Introduction hardstatus [always]lastline|message|ignore Basic Screen [string] screenrc File hardstatus string [string] Advanced Screen » Password Protection » Copy/Paste � The first form toggles the hardware status line. » Logging » Hardstatus Line � The second form identifies how to handle the hardstatus line. » Hardstatus Line String (1/2) » Hardstatus Line String (2/2) � ‘lastline’ will reserve the last line of the display for the » Backtick » Horizontal Screen Split hardstatus. Crazy Screen � ‘message’ uses screen’s message mechanism Questions � ‘ignore’ tells screen never to display the hardstatus. � If ‘always’ is prepended to the type (e.g. ‘alwayslastline’), screen will always show the type selected. � The third form specifies the contents of the hardstatus line. Matt G. Habib & Ryan Curtin GNU Screen - p. 15/26

Recommend


More recommend