Quick Links
Using Screen for Managing Multiple Terminal Windows
The screen program allows you to multiplex a physical terminal into one or more interactive shells. This program is especially useful for remotely accessing the lab machines. Using the screen program, you can start multiple shells on a lab machine from a single PUTTY or xterm terminal. This is especially beneficial for debugging ECE344 code that requires running multiple programs, such as a client and a server. You can run one program from one window, while running run the other program within a debugger in the other window.
A second benefit of screen is that upon hangup (e.g., if your PUTTY session is killed accidentally), it saves all your running programs until they are resumed with the screen -DR command.
To start using screen, create a ~/.screenrc file with the following contents. The first command allows scrolling back a large number of lines. The second command sets up Ctrl-z as the screen escape character that allows you to issue screen commands. The default default screen escape character is Ctrl-a, but that can interfere with line editing commands. If you want to suspend a process, use Ctrl-z a, instead of the default Ctrl-z. The last two lines add a status line at the bottom of the terminal.
defscrollback 10000 escape ^za hardstatus alwayslastline hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
Start screen by issuing the screen command. If you want to start another screen window, type Ctrl-z c, which creates a new window. You can see all the windows, by typing Ctrl-z ”. You can switch between windows by typing Ctrl-z n or Ctrl-z p. You can finish or kill a screen session by typing Ctrl-D.
Say you wish to stop working on your OS lab (it is 4 am). You can detach from screen by typing Ctrl-z d. This stops screen but keeps your programs running.
You can log out of the lab machine. Later, you can log back in. To resume screen, type screen -DR. You should see all your screen windows in the state you left them in when you detached from screen.
Screen has a lot of features. You can get help by typing Ctrl-z ?, or you can read its manual page by running man screen.