GNU Screen a Terminal Multiplexer
Total Page:16
File Type:pdf, Size:1020Kb
GNU Screen A Terminal Multiplexer Sebastian Panknin Institut of Physics Humboldt University of Berlin 2008-08-19 / IceTray Seminar Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 1 / 11 Outline 1 Motivation 2 A Basic Session 3 Srolling and Logging 4 Windows 5 Advanced Sessions Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 2 / 11 The Problem People like to do heavy calculations on their working computers but like to log in from home. Working at different computers can be annoying not all processes can be put in background (problem with IO) you want to log out, but your job wants to run for another 30 hours working from home/airport/conference location tomorrow Also would be nice Is there somewhere the word “Foo” in the 500 lines output? I have forgotten to pipe it in a file. Can I share a shell session with an expert? The solution: GNU Screen Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 3 / 11 Simple Use Case Basic Session First starting Screen: When you have screen started a screen do what ever you want in the shell session, you can detach from screen with C-a d leave it and resume Later (maybe from a new shell over ssh): it whenever you want. Programs reopen screen with screen -r running in the screen do what ever you want in the shell won’t notice. detach again, . Screen ends if you exit the shell. Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 4 / 11 Basic Session Commands I don’t want to listen to the talk, so where is more information available? Screen Help man page: man screen info page: info screen on-line help inside screen: C-a ? Good to know analogous for the confusing C-s: C-a s – use C-a q to make it going again. list of open screen sessions: screen -list connect to a specific session: screen -r pid.tty.host Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 5 / 11 The Scroll Buffer Starting the “Copying and Scroll Mode” with C-a [ Movements cursor keys Vi like movement keys C-u and C-d scrolls up and down Searching Vi forward search / and backward ? incremental forward C-a s and backward: C-r Exit with ESC Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 6 / 11 Logging Forgotten to pipe the output into a file? – Screen helps: If you found something interesting in the scroll back buffer make a hard copy or if you hope for something interesting turn the logging on. Start/stop logging of current window: C-a H Save window content in a file: C-a : hardcopy -h filename Time stamps: C-a : logtstamp toggles the time stamp state. If it is on, a time stamp is written if the program gets inactive. Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 7 / 11 Window Management Opening many ssh-connections is annoying, but having only one shell is Switching Windows unpractical, too. – Screen allows many to specific window: C-a shells over one connection. 0 ... C-a 9 next/previous: C-a n create a new window with C-a c resp. C-a p window list: C-a " to the last used: C-a windows close by exit of the shell C-a Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 8 / 11 Fancy Window Stuff Displaying Several Windows at One Time Split the display with C-a S. The new region shows a blank window. cycle through the regions: C-a TAB remove current region: C-a X only one region again: C-a Q Monitoring A message can be displayed if a output starts/stops in a hidden window. activity monitoring: C-a M inactivity monitoring: C-a Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 9 / 11 Using Multiple Sessions Sometime one runs multiple screen sessions. detach session: screen -d pid.sessionname reattach session: screen -r pid.sessionname powerful combination reattach and if needed detach fist: screen -d -r also create a session if needed: screen -d -R as above but take the first session: screen -d -RR attach an attached session without detaching: screen -xR Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 10 / 11 Summary Screen is useful for running programs in background, access a running program from different locations, logging and searching in command output. It also supports I window management I multiuser sessions. Sebastian Panknin (Humboldt University) GNU Screen IceTray Seminar 11 / 11.