1 screen primer

1.1 Introduction

Screen is a window manager for text terminals. It's very useful for managing your virtual environment, particularly when you are teaching with other instructors.

Ansible installed a .screenrc configuration file onto your server and we'll assume that you are using the NSRC's custom screen configuration for these exercises.

You'll start a screen session from the command line. It's good practice to check what sessions are currently running on your server before starting a new one.

1.2 Show existing screen sessions

Ssh to your server:

$ ssh nsrc@s1.ws.nsrc.org

List any existing screen sessions:

 $ screen -ls

There shouldn't be any screen sessions.

1.3 Start a new session

Now that you've confirmed that there are no sessions, create a new screen session named workshopX (e.g. workshop1, workshop2, workshop3). Agree with your partners what you will name your sessions. Each person should pick a unique session name in your group.

$ screen -S workshopX       

You should see the status bar at the bottom of your screen with 3 windows named shell1, shell2, and shell3. You can also list your session and those of your partners with:

$ screen -ls

1.4 Working with your session

You have 3 windows in your session. Let's create a new window. Type C-x C-c to create the new window. It will be named bash.

Let's give it a more useful name. Type C-x A (this is case-sensitive) and you'll see the following prompt at the bottom of your screen:

Set window's title to:

Delete bash and name your new window compile. The status bar at the bottom of your screen will be updated when you hit return.

Now navigate to a new window with C-x n. You can return to the previous window with C-x p.

Next navigate to the window labeled "shell2" and kill it with C-x k. Then type y to confirm that you want to kill the current window.

Let's start a program that will update continously:

$ watch --interval 1 date

Finally detach from your session with C-x d.

Now you will connect to one of your partner's screen sessions. You should be at the command line and not in a screen session. If your partner created a session named workshop2, you would use

$ screen -r -d workshop2

Navigate through the windows until you find the one running the watch --interval 1 date command. Kill the process by typing C-c and then detach from your partner's session with C-x d.

2 Command mode cheat sheet

C == Control

Screen's default command sequence is C-a. We've redefined this as C-x because C-a is used by other programs, most importantly bash command line editing.

C-x C-c new window

C-x A name window

C-x k kill window

C-x d detach from session

C-x n,p next or previous window

C-x 1,2,3 move to specific window

C-x ESC enter scrollback mode