UnixCommands/Screen

From S23Wiki
Jump to: navigation, search

About screen

screen is a "window" manager for the terminal. Similar in concept to tabbed browsing in Mozilla, but without the GUI. It allows you to have multiple terminal sessions open while only taking up one on your desktop (aka console).

When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill existing windows, view a list of windows, turn output logging on and off, copy-and-paste text between windows, view the scrollback history, switch between windows in whatever manner you wish, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user's terminal. When a program terminates, screen (per default) kills the window that contained it. If this window was in the foreground, the display switches to the previous window; if none are left, screen exits.

invoking screen

Invoke screen like so:

screen <command> <argument/s> 
example:
screen irssi -c irc.rt.ru


attaching to a screen

screen -x
screen -r

detaching from screen

Ctrl+a+d

switching to next screen window

Ctrl+a+n

screen keyboard shortcuts

By default, once you have invoked screen as mentioned above, each command begins with a control-a (abbreviated C-a from now on), and is followed by one other keystroke. The command character and all the key bindings can be fully customized to be anything you like, though they are always two characters in length.

"C-a c"   - The standard way to create a new window
"C-a n"   - Toggle to next window
"C-a p"   - Toggle to previous window
"C-a 0-9" - Switch to window #
"C-a d"   - Detach from current screen back to shell (screen runs in background)

If you have detached from ScreeN and would like to resume/reattach try this:

screen -r

screen Manpage
Some customizations explained here

Multiple screens

If you have multiple screens running, use

screen -x or screen -l

to list them with their [pid.]tty.host and type either

screen -x [pid.]tty.host  
screen -r [pid.]tty.host (thanks to whoever mentioned this)