The basic screen commands:
ctrl-a c creates a new shell
ctrl-a n go to the next shell
ctrl-a p go to the previous shell
ctrl-a " shows a list of all the shells. Select a shell with the cursor keys & hit enter.
In the window list, , . move the highlighted window up or down the list.
ctrl-a ctrl-a toggles between 2 shells
More advanced commands:
ctrl-a d detach the current shell, making it a daemon. You can log out without ending it.
screen -r [daemon name] reattaches to a daemon & shows the terminal output
screen -ls shows the daemons
Splitting a screen:
The xterm scroll buffer is useless in split screen mode, but it can be useful if you're only using 11 rows.
ctrl-a shift-s splits the screen
ctrl-a ctrl-i toggle between panels. Once in a different panel, use ctrl-a " to select a shell to show in it
ctrl-a shift-q unsplit the screen, keeping the current panel
ctrl-a shift-x unsplit the screen, keeping the other panel
Scrolling in screen:
Screen by default doesn't use the xterm scroll buffer, but has its own buffer which is intended for copying text.
ctrl-a ESC enters the copy mode
In copy mode, ? / n cause it to search for text the same as less & vi, but it doesn't show line numbers or wrap around. g G cause it to go to the start & end.
cursor keys & pgup scroll back
ESC 3 times escapes from the copy mode
To erase the scroll buffer, you have to enter 2 commands with crtl-a :
scrollback 0
scrollback 1000
To make screen more intuitive, it must be forced to use the xterm scroll buffer by editing /etc/screenrc
This magic line should already be in /etc/screenrc & just needs to be uncommented:
termcapinfo xterm|xterms|xs|rxvt ti@:te@
The xterm scroll buffer is not swapped when changing shells. You still have to go back to abusing the copy feature for that. Lions used to jump around the screen program like a pro & screen's disabling of the xterm scroll buffer makes lions believe it was originally just needed on vt100's.
The screenrc file also allows binding custom commands to keys, like erasing the scroll buffer.
Giving shells useful titles

The lion screen program has the hostname & directory of all is shells, but it doesn't do this by default.
The titles of the screens have to be customized. In Linux, it's done by appending a kludge to print an escape sequence right before the command prompt. It can't show the currently running program but it can show the prompt. It takes some doing to delete all the other PS1 declarations & make sure this is the only one:
export PS1='`whoami`@`hostname`:`pwd`% '
# customize the screen title
case $TERM in
screen*)
# ESC k ESC \ tells screen to set its title
SCREENTITLE='\[\ek`whoami`@`hostname`:\w\e\\\]'
;;
*)
SCREENTITLE=''
;;
esac
PS1="${SCREENTITLE}${PS1}"
On Ubunt, it has to be appended to the end of /etc/profile & all the PS1 declarations in ~/.bashrc have to be commented out.
Since its revival in 2019, the screen program has been a game changer. Lions spent over 20 years running the script program, loading typescript files, redirecting stderr to files & loading the files to view lengthy console output. It was a real pane to debug programs with long console output.
Having an adjustable scroll buffer with search functionality replaced all that with much simpler commands. It might have been a stretch to have a large scroll buffer when screen was introduced in 1987, but now the scroll buffer can easily replace a debug file.