Linux Screen Command – Window Management At It’s Best
Just in case you haven’t heard about Screen or don’t know what the Linux Screen Command is about, in short – Screen is the de-facto window manager in a Linux/Unix environment.
Not only does Screen let you open and switch between multiple windows, Screen also let’s you run programs in it’s won environment, even if you close the current SSH session. This comes in handy when you have scripts that run for a long time and could potentially timeout in SSH.
Another handy feature is to establish your window sessions, perhaps modifying several files in Vim, then log out for lunch and come back to find your windows just like when you left.
Let’s get started using the Linux Screen Command
Connect to a remote computer using a terminal via SSH. If you haven’t installed Screen already, you can do so using your distro’s package manager (in Ubuntu: sudo apt-get install screen). Once installed, start it:
The first time, you’re greeted with welcome message. Hit space and you’re in. At this point, you have one window and you’re using it at the moment. All commands in Screen are escaped by “Ctl A”. For example, to open another window, press “Ctl A” followed by “c”. For the sake of demonstration, open the program “top” followed by “Ctl A” + “p”. That gets you back to the initial window. Lets start vi. Then “Ctl A” + “n”, and you’re back at the previous windows running top.
Most useful Screen commands
Now that you know the escape character and how to issue screen commands, let’s look at some of the most used ones.
$ screen (start screen)
Ctl A + c (create window)
Ctl A + n (next window)
Ctl A + p (previous window)
Ctl A + d (detach from session, for example to close ssh without loosing screen windows)
Ctl A + r (re-attach to session)
Ctl A + -ls (list of running sessions)
Ctl A + r <name> (re-attach to session by name)
Ctl A + A (rename current window)
Ctl A + ” (list of running windows)
Ctl A + Ctl A (switch back and forth between two windows)
Ctl A + k (kill current window, so does “exit”)
Ctl A + S (split display horizontally)
Ctl A + V (split display vertically)
Ctl A + tab (move between split areas)
Remember, closing the current window without detaching closes all applications in it.
More complete list of commands
Command key: ^A break ^B b lockscreen ^X x reset Z clear C log H screen ^C c colon : login L select " ' copy ^[ [ meta a silence _ detach ^D d monitor M split S digraph ^V next ^@ ^N sp n suspend ^Z z displays * number N time ^T t fit F only Q title A flow ^F f other ^A vbell ^G focus ^I pow_break B version v help ? pow_detach D width W history prev ^P p ^? windows ^W w info i readbuf < wrap ^R r kill K redisplay ^L l writebuf > lastmsg ^M m remove X xoff ^S s license , removebuf = xon ^Q q [Press Space for next page; Return to end.]