How do I Use Multiple Screens on One Terminal over ssh session?
Most of the time GUI is not available on remote Linux system, you login over ssh and start to work, if you need to run two or three task at a time, you login over ssh two or three times. However, with screen windows manager utility you can run multiple terminals at the same time from single console login over ssh session (UNIX guru uses the term called multiplexing for this concept). Any seasoned Linux admin should be aware of this nifty tool.
Install screen if it is not installed under Debian Linux
Type the following command:
# apt-get install screen
FreeBSD user can use ports to install screen
# cd /usr/ports/misc/screen
# make install clean
Login to remote server over ssh
$ ssh me@myserver.com
(C) Start screen session. You can name your window/session (1 is name of session):
$ screen -S 1
Let us start pine mail reader on first session or window.
$ pine
(D) Next you would like to download something from ftp/http site while you are reading emails. You need to create another screen window by pressing special key combination. Press CTRL + a followed by c key (first hit CTRL+a, releases both keys and press c). As soon as you hit 'c' you will get new shell prompt at console. Now use wget to download belenix.iso.bz2 (Solaris live CD) from net:
$ wget http://www.genunix.org/distributions/belenix_site/binfiles/belenix.iso.bz2
(E) But how do I switch between these two tasks?
- Switching between windows is the specialty of screen utility. So to switch between pine and wget window (or session) press CTRL+a followed by n key (first hit CTRL+a, releases both keys and press n).
- To list all windows use the command CTRL+a followed by " key (first hit CTRL+a, releases both keys and press " ).
- To switch to window by number use the command CTRL+a followed by ' (first hit CTRL+a, releases both keys and press ' it will prompt for window number).
Common screen commands
screen command | Task |
Ctrl+a c | Create new window |
Ctrl+a k | Kill the current window / session |
Ctrl+a w | List all windows |
Ctrl+a 0-9 | Go to a window numbered 0 9, use Ctrl+a w to see number |
Ctrl+a Ctrl+a | Toggle / switch between the current and previous window |
Ctrl+a S | Split terminal horizontally into regions and press Ctrl+a c to create new window there |
Ctrl+a :resize | Resize region |
Ctrl+a :fit | Fit screen size to new terminal size. You can also hit Ctrl+a F for the the same task |
Ctrl+a :remove | Remove / delete region. You can also hit Ctrl+a X for the same taks |
Ctrl+a tab | Move to next region |
Ctrl+a D (Shift-d) | Power detach and logout |
Ctrl+a d | Detach but keep shell window open |
Ctrl-a Ctrl-\ | Quit screen |
Ctrl-a ? | Display help screen i.e. display a list of commands |
Suggested readings:
See screen command man page for further details:
man screen
man screen
No comments:
Post a Comment