1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
---|
6 | <meta name="generator" content="pandoc" /> |
---|
7 | <title></title> |
---|
8 | <style type="text/css">code{white-space: pre;}</style> |
---|
9 | </head> |
---|
10 | <body> |
---|
11 | <div id="TOC"> |
---|
12 | <ul> |
---|
13 | <li><a href="#screen-primer"><span class="toc-section-number">1</span> screen primer</a><ul> |
---|
14 | <li><a href="#introduction"><span class="toc-section-number">1.1</span> Introduction</a></li> |
---|
15 | <li><a href="#show-existing-screen-sessions"><span class="toc-section-number">1.2</span> Show existing screen sessions</a></li> |
---|
16 | <li><a href="#start-a-new-session"><span class="toc-section-number">1.3</span> Start a new session</a></li> |
---|
17 | <li><a href="#working-with-your-session"><span class="toc-section-number">1.4</span> Working with your session</a></li> |
---|
18 | </ul></li> |
---|
19 | <li><a href="#command-mode-cheat-sheet"><span class="toc-section-number">2</span> Command mode cheat sheet</a></li> |
---|
20 | </ul> |
---|
21 | </div> |
---|
22 | <h1 id="screen-primer"><a href="#screen-primer"><span class="header-section-number">1</span> screen primer</a></h1> |
---|
23 | <h2 id="introduction"><a href="#introduction"><span class="header-section-number">1.1</span> Introduction</a></h2> |
---|
24 | <p>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.</p> |
---|
25 | <p>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.</p> |
---|
26 | <p>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.</p> |
---|
27 | <h2 id="show-existing-screen-sessions"><a href="#show-existing-screen-sessions"><span class="header-section-number">1.2</span> Show existing screen sessions</a></h2> |
---|
28 | <p>Ssh to your server:</p> |
---|
29 | <pre><code>$ ssh nsrc@s1.ws.nsrc.org</code></pre> |
---|
30 | <p>List any existing screen sessions:</p> |
---|
31 | <pre><code> $ screen -ls</code></pre> |
---|
32 | <p>There shouldn't be any screen sessions.</p> |
---|
33 | <h2 id="start-a-new-session"><a href="#start-a-new-session"><span class="header-section-number">1.3</span> Start a new session</a></h2> |
---|
34 | <p>Now that you've confirmed that there are no sessions, create a new screen session named <em>workshopX</em> (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.</p> |
---|
35 | <pre><code>$ screen -S workshopX </code></pre> |
---|
36 | <p>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:</p> |
---|
37 | <pre><code>$ screen -ls</code></pre> |
---|
38 | <h2 id="working-with-your-session"><a href="#working-with-your-session"><span class="header-section-number">1.4</span> Working with your session</a></h2> |
---|
39 | <p>You have 3 windows in your session. Let's create a new window. Type <strong>C-x C-c</strong> to create the new window. It will be named <em>bash</em>.</p> |
---|
40 | <p>Let's give it a more useful name. Type <strong>C-x A</strong> (this is case-sensitive) and you'll see the following prompt at the bottom of your screen:</p> |
---|
41 | <p><code>Set window's title to:</code></p> |
---|
42 | <p>Delete <em>bash</em> and name your new window <strong>compile</strong>. The status bar at the bottom of your screen will be updated when you hit return.</p> |
---|
43 | <p>Now navigate to a new window with <strong>C-x n</strong>. You can return to the previous window with <strong>C-x p</strong>.</p> |
---|
44 | <p>Next navigate to the window labeled "shell2" and kill it with <strong>C-x k</strong>. Then type <strong>y</strong> to confirm that you want to kill the current window.</p> |
---|
45 | <p>Let's start a program that will update continously:</p> |
---|
46 | <pre><code>$ watch --interval 1 date</code></pre> |
---|
47 | <p>Finally detach from your session with <strong>C-x d</strong>.</p> |
---|
48 | <p>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</p> |
---|
49 | <pre><code>$ screen -r -d workshop2</code></pre> |
---|
50 | <p>Navigate through the windows until you find the one running the <code>watch --interval 1 date</code> command. Kill the process by typing <strong>C-c</strong> and then detach from your partner's session with <strong>C-x d</strong>.</p> |
---|
51 | <h1 id="command-mode-cheat-sheet"><a href="#command-mode-cheat-sheet"><span class="header-section-number">2</span> Command mode cheat sheet</a></h1> |
---|
52 | <p>C == Control</p> |
---|
53 | <p>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.</p> |
---|
54 | <p><strong>C-x C-c</strong> <em>new window</em></p> |
---|
55 | <p><strong>C-x A</strong> <em>name window</em></p> |
---|
56 | <p><strong>C-x k</strong> <em>kill window</em></p> |
---|
57 | <p><strong>C-x d</strong> <em>detach from session</em></p> |
---|
58 | <p><strong>C-x n,p</strong> <em>next or previous window</em></p> |
---|
59 | <p><strong>C-x 1,2,3</strong> <em>move to specific window</em></p> |
---|
60 | <p><strong>C-x ESC</strong> <em>enter scrollback mode</em></p> |
---|
61 | </body> |
---|
62 | </html> |
---|