-- screen program allows you to use multiple windows[Virtual consoles] in UNIX/LINUX, with one remote login session.
-- all virtual console devices can be open at once, but only one is active at a time
Useful-- when you log on to the the remote server
Scenarios
---When you log on to the remote server(using ssh,telent,etc), you may need more windows/terminal for the same host. But you do want to open multiple terminal from your host and many log on to the same host
---You have logged into the remote system,doing work. Suddenly connection closed(due to some network errors or may even your system failure). You have lost the session to remote system, and also lost work done.
Solution
--- use the screen manager once you log on the remote server.
How to use:
1. Once you log on to the remoter server launch the screen manager((/usr/local/bin/screen @ FreeBSD, check with your system) .
2. Create multiple windows using the following command
Eg:
Once you log on the remote host run
screen
Create a screen and remains in the same window
Ctrl+ a c -- creates a new window
Ctrl+ a w -- list the windows created. * mark indicates the active window
Ctrl+a A(Shift+a) -- Set title for the current window
Ctrl+a k -- kill the current window
Ctrl+a n -- go to the nth window
Ctrl+a Ctrl+a -- toggle between current window and previous window
Ctrl+a ? -- Display help
exit -- exit the current window (as usual to UNIX terminal exit)
Ctrl+a d -- detach the screen (Screen keeps on running, you can attach later)
You can find more options with Cntrl+a ? (Shift+?)
screen -ls -- will show the what are all the screens running behalf of you
screen -r
I will explain more features in future
Following is a sample configure file .screenrc. Place this file at your home directory /home/user/.screenrc
# skip the startup message
startup_message off
# go to home dir
chdir
# Automatically detach on hangup.
autodetach on
# Change default scrollback value for new windows
defscrollback 1000
# start with visual bell as default
vbell on
vbell_msg "bell on %t (%n)"
# look and feel
caption always "%{= bb}%{+b w}%n %h %=%t %C%a"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
activity "^GActivity in %t(%n)"
bell_msg "^GBell in %t(%n)"
bindkey -k P prev
bindkey -k N next
shelltitle "shell"
#Number of login shells to be open when screen creteatd in
screen -t SHELL 0 bash
screen -t SHELL 1 bash
screen -t SHELL 2 bash