Screen
(adding a section on split windows) |
(* [http://ryandlane.com/blog/2011/03/23/screen-with-ssh-on-a-shell-server/ Ryan's blog with really nice additions to .screenrc/.bashrc]) |
||
| Line 54: | Line 54: | ||
== External link == | == External link == | ||
* http://www.guckes.net/screen/ Sven Guckes screen pages | * http://www.guckes.net/screen/ Sven Guckes screen pages | ||
| + | * [http://ryandlane.com/blog/2011/03/23/screen-with-ssh-on-a-shell-server/ Ryan's blog with really nice additions to .screenrc/.bashrc] | ||
[[Category:How-To]] | [[Category:How-To]] | ||
Revision as of 14:04, 8 September 2011
screen is a terminal multiplexer.
Once logged in on a server, use 'screen bash' and you will have another bash in a virtual window. From there you can add other windows with different program and move from a window to another. Ultimatly, you can send screen in the background & logout : screen will detach and run in the background.
Example:
hashar@bihash:$ ssh aserver $ screen bash
A new bash is invoked, my xterm title show:
[screen 0: bash] hashar@zwinger:~
This means I am in the screen window #0 and running bash.
$ vmstat 1 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 2 0 65508 51500 106756 430740 2 1 3 4 6 6 7 14 65 14 0 0 65508 51372 106764 430732 0 0 12 24 0 0 2 15 82 2 0 0 65508 51404 106768 430728 0 0 8 0 0 0 1 10 88 1 and so on ...
Contents |
Multiple windows inside one screen
I am monitoring the server. Now let's create another window to edit a file. This is done by using CTRL + A then C (for create).
A new bash is invoked, my xterm title show:
[screen 1: bash] hashar@zwinger:~
I can do whatever I want there. To move back to the window with vmstat use CTRL + A then P (for previous), to switch again CTRL + A then N (for next).
Splitting windows
You can also split a screen to see more than one window at once. Use CTRL + A then S (yes, that's a capital S, so SHIFT + s, for Split), then use CTRL + A then <Tab> to switch between them. Now you can create a new window, using CTRL + A then C as described above and keep switching betweem them using Tab.
Detaching and Re-attaching
Finally it's dinner time or you need to reboot your computer, or whatever. You can send screen in the background and logout, that will keep all your program running. This is done with CTRL + A then D (for detach).
$ screen bash [detached] $ ps fx 13178 ? S 0:00 SCREEN bash 13179 pts/1235 S 0:00 \_ bash 13249 pts/1236 S 0:00 \_ /bin/bash
Screen is in the background. Now you can logout. Once logged back, you want to resume your backgrounded screen:
$ screen -r
You are back to the vmstat stuff which is still spamming values :)
Finally log out of all windows, when there is none left, screen exit:
[screen is terminating] $
External link
- http://www.guckes.net/screen/ Sven Guckes screen pages
- Ryan's blog with really nice additions to .screenrc/.bashrc