Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Changed: | ||||||||
< < | -- WilliamBreadenMadden - 2011-11-14 | |||||||
> > | -- WilliamBreadenMadden - 2012-03-20 | |||||||
Line: 12 to 12 | ||||||||
Screen | ||||||||
Added: | ||||||||
> > | Happy birthday, Screen! | |||||||
General descriptionThere can be certain limitations when using SSH to connect to a server. For examples, in order to open a new window, a second SSH connection to the server must be created; if the connection is lost* during the SSH tunnel, progress is lost. Screen is useful in tackling both of these problems. |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Line: 30 to 30 | ||||||||
To close a window, the "exit" command can be used (as in a normal shell). This will cause one to fall back to the previous monitor one opened, or to one's main prompt (from which screen was started). | ||||||||
Changed: | ||||||||
< < | One of the biggest advantages of using screen is that one can "detach" a screen session. This means one returns to the normal shell, but the processes started in screen remain active in the background. To detach, press Ctrl + a, followed by d (for "detach"). Basically, one can start a number of processes, exit the shell and return some time later to pick up the session started in screen. Further, should one be disconnected accidentally during a screen session, one can pick up the (detached) screen session. To "reattach", SSH to the shell of the server that screen was being run on. To present a list of the current screen sessions running, use the "screen -ls" command. To resume one of these listed previous screen sessions, use the "screen -r | |||||||
> > | One of the biggest advantages of using screen is that one can "detach" a screen session. This means one returns to the normal shell, but the processes started in screen remain active in the background. To detach, press Ctrl + a, followed by d (for "detach"). Basically, one can start a number of processes, exit the shell and return some time later to pick up the session started in screen. Further, should one be disconnected accidentally during a screen session, one can pick up the (detached) screen session. To "reattach", SSH to the shell of the server that screen was being run on. To present a list of the current screen sessions running, use the "screen -ls" command. To resume one of these listed previous screen sessions, use the "screen -r " command. One can actually type simply the first few characters of the session name (enough to identify that session) or, indeed, if there is only one session running, one need use only the "screen -r" ("r" for "resume") command. If a screen session is still attached, it can not be resumed before it is detached. | |||||||
Example using CERN LXPLUS | ||||||||
Line: 141 to 141 | ||||||||
Unlock a frozen SSH sessionTo unlock a frozen SSH session (e.g. after connection timeout) without needing to open a new shell, press Enter, then tilde, then period. | ||||||||
Added: | ||||||||
> > | Make "delete" work properly in text editingWhen I ssh to lxplus machines at CERN and I try to edit a file, either with emacs, nano or pico, when I press the backspace key it does not remove the character to the left of the cursor as it should. The following solutions solves the problem in the xterm ran after the ssh command, but not in the initial window. You need to create this file in your home area[abuzatu@lxplus401]~% emacs -nw ~/.Xdefaultsthen add this line in the file *VT100.Translations: #override \ <Key>BackSpace: string(0x7F)\n\ <Key>Delete: string("\033[3~")\n\ <Key>Home: string("\033[1~")\n\ <Key>End: string("\033[4~") *ttyModes: erase ^?
At lxplus machines edit .zshrcWhen I ssh to lxplus machines at CERN the default shell is /bin/zsh, so if you want to add aliases of your own, you have to edit the file ~/.zshrc. | |||||||
-- WilliamBreadenMadden - 2011-08-25 \ No newline at end of file | ||||||||
Added: | ||||||||
> > | -- AdrianBuzatu - 2012-02-01 |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Changed: | ||||||||
< < | -- WilliamBreadenMadden - 2011-08-26 | |||||||
> > | -- WilliamBreadenMadden - 2011-11-14 | |||||||
Line: 128 to 128 | ||||||||
That was fun, wasn't it? | ||||||||
Added: | ||||||||
> > | Screen tips and tricks | |||||||
Changed: | ||||||||
< < | Miscellaneous Information and Helpful Tips | |||||||
> > | Copy Mode | |||||||
Changed: | ||||||||
< < | To unlock a frozen ssh session (e.g. after connection timeout) without needing to open a new shell, press enter, then tilde, then period. | |||||||
> > | Enter the copy buffer mode by pressing Ctrl + a , followed by Esc. | |||||||
Added: | ||||||||
> > | In copy buffer mode, you can move the cursor freely using directional keys.
SSH tips and tricksUnlock a frozen SSH sessionTo unlock a frozen SSH session (e.g. after connection timeout) without needing to open a new shell, press Enter, then tilde, then period. | |||||||
-- WilliamBreadenMadden - 2011-08-25 \ No newline at end of file |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Line: 128 to 128 | ||||||||
That was fun, wasn't it? | ||||||||
Added: | ||||||||
> > |
Miscellaneous Information and Helpful TipsTo unlock a frozen ssh session (e.g. after connection timeout) without needing to open a new shell, press enter, then tilde, then period. | |||||||
-- WilliamBreadenMadden - 2011-08-25 \ No newline at end of file |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Line: 127 to 127 | ||||||||
That was fun, wasn't it? \ No newline at end of file | ||||||||
Added: | ||||||||
> > | -- WilliamBreadenMadden - 2011-08-25 | |||||||
\ No newline at end of file |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Changed: | ||||||||
< < | -- WilliamBreadenMadden - 2011-08-25 | |||||||
> > | -- WilliamBreadenMadden - 2011-08-26 | |||||||
Line: 66 to 66 | ||||||||
Now, detach from your screen session by pressing Ctrl + a, followed by d. | ||||||||
Changed: | ||||||||
< < | You should arrive back at the main prompt (from which screen was started) | |||||||
> > | You should arrive back at the main prompt (from which screen was started), | |||||||
[wbm@lxplus429]~% | ||||||||
Line: 78 to 78 | ||||||||
[wbm@lxplus429]~% exit | ||||||||
Changed: | ||||||||
< < | You should now be back at your local machine. | |||||||
> > | You should now be back at your local computer. | |||||||
Connection to lxplus.cern.ch closed. | ||||||||
Line: 120 to 120 | ||||||||
[wbm@lxplus429]~% exit | ||||||||
Changed: | ||||||||
< < | Now, you are back at your local machine. | |||||||
> > | Now, you are back at your local computer. | |||||||
wbm@dungeonoflove:~$ |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Line: 100 to 100 | ||||||||
1 Socket in /var/run/screen/S-wbm | ||||||||
Changed: | ||||||||
< < | Next, you can resume this screen session using the "screen -r <name_of_session>" command. Remember that you need use only the the first few characters (or you can simply use "screen -r" to resume is you have only one session running) of the session name to identify it... | |||||||
> > | Next, you can resume this screen session using the "screen -r name_of_session" command. Remember that you need use only the the first few characters (or you can simply use "screen -r" to resume is you have only one session running) of the session name to identify it... | |||||||
[wbm@lxplus429]~% screen -r 17779.pts-45.lxplus429 |
Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
SSH* description of SSH *ScreenGeneral descriptionThere can be certain limitations when using SSH to connect to a server. For examples, in order to open a new window, a second SSH connection to the server must be created; if the connection is lost* during the SSH tunnel, progress is lost. Screen is useful in tackling both of these problems. Screen is a useful tool that allows the use of multiple screens over one SSH connection. You might have separate processes running in each of these screens. Screen is installed by default on most installations. The presence of screen can be verified using the "which screen" command. Screen can be installed easily using apt or yum.Using screenScreen can be started by entering "screen". You should now be in a new screen, ready to enter commands. Screen has a few commands in order to manipulate windows, navigate through open ones, "detach" and "attach", among other commands. The entire command list can be shown by pressing Ctrl + a, followed by ?. (By pressing Ctrl + a, it is indicated that the next signal is to be sent to screen, as opposed to the shell.) To start a new window press Ctrl + a, followed by c (for "create"). A new window should now be created. To cycle through the various open windows, press Ctrl + a, followed by n (for "next"). To cycle through the various open windows in the opposite direction, press Ctrl + p, followed by p ("for previous"). To view a list of all open windows (from which a particular window can be selected), press Ctrl + a, followed by " (i.e., you might press Ctrl + a, followed by Shift + '.) To close a window, the "exit" command can be used (as in a normal shell). This will cause one to fall back to the previous monitor one opened, or to one's main prompt (from which screen was started). One of the biggest advantages of using screen is that one can "detach" a screen session. This means one returns to the normal shell, but the processes started in screen remain active in the background. To detach, press Ctrl + a, followed by d (for "detach"). Basically, one can start a number of processes, exit the shell and return some time later to pick up the session started in screen. Further, should one be disconnected accidentally during a screen session, one can pick up the (detached) screen session. To "reattach", SSH to the shell of the server that screen was being run on. To present a list of the current screen sessions running, use the "screen -ls" command. To resume one of these listed previous screen sessions, use the "screen -rExample using CERN LXPLUSSSH in to LXPLUS.wbm@dungeonoflove:~$ ssh -Y wbm@lxplus429.cern.chStart a screen session. [wbm@lxplus429]~% screenDo something in this window. [lxplus429] ~ % topCreate a new window by pressing Ctrl + a, followed by c. Do something in this new window. (In this example, I have the terminal print the time and date every second until the process is stopped using Ctrl + z.) [lxplus429] ~ % while date; do sleep 1; doneTry switching between your two windows by pressing Ctrl + a, followed by n, or by pressing Ctrl + a, followed by p. Try viewing a list of your open windows by pressing Ctrl + a , followed by ". Now, detach from your screen session by pressing Ctrl + a, followed by d. You should arrive back at the main prompt (from which screen was started) [wbm@lxplus429]~%Now, disconnect from LXPLUS (or, for added fun, simulate an accidental disconnection by turning off your internet connection...). [wbm@lxplus429]~% exitYou should now be back at your local machine. Connection to lxplus.cern.ch closed. wbm@dungeonoflove:~$Now, SSH back to that same server you were using. wbm@dungeonoflove:~$ ssh -Y wbm@lxplus429.cern.chHere comes the exciting part... Using the "screen -ls" command, you can see a list of the current screen sessions running... [wbm@lxplus429]~% screen -ls There is a screen on: 17779.pts-45.lxplus429 (Detached) 1 Socket in /var/run/screen/S-wbmNext, you can resume this screen session using the "screen -r <name_of_session>" command. Remember that you need use only the the first few characters (or you can simply use "screen -r" to resume is you have only one session running) of the session name to identify it... [wbm@lxplus429]~% screen -r 17779.pts-45.lxplus429You should now be back in your screen session! You can exit your screen windows (and, eventually, your screen session when all screen windows are closed) using the "exit" command. [lxplus429] ~ % exitYou can exit the SSH tunnel using the "exit" command. [wbm@lxplus429]~% exitNow, you are back at your local machine. wbm@dungeonoflove:~$That was fun, wasn't it? |