summaryrefslogtreecommitdiffstats
path: root/slackbook/html/shell-vt.html
blob: 2d28160c57074e683476b1b818669c41a3d10fd1 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Virtual Terminals</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="UP" title="The Shell" href="shell.html" />
<link rel="PREVIOUS" title="The Bourne Again Shell (bash)" href="shell-bash.html" />
<link rel="NEXT" title="Filesystem Structure" href="filesystem-structure.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>

<tr>
<td width="10%" align="left" valign="bottom"><a href="shell-bash.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 8 The Shell</td>
<td width="10%" align="right" valign="bottom"><a href="filesystem-structure.html"
accesskey="N">Next</a></td>
</tr>
</table>

<hr align="LEFT" width="100%" />
</div>

<div class="SECT1">
<h1 class="SECT1"><a id="SHELL-VT" name="SHELL-VT">8.4 Virtual Terminals</a></h1>

<p>So you're in the middle of working on something and you decide you need to do
something else. You could just drop what you're doing and switch tasks, but this is a
multi-user system, right? And you can log in as many times simultaneously as you want,
right? So why should you have to do one thing at a time?</p>

<p>You don't. We can't all have multiple keyboards, mice, and monitors for one machine;
chances are most of us don't want them. Clearly, hardware isn't the solution. That leaves
software, and Linux steps up on this one, providing &#8220;virtual terminals&#8221;, or
&#8220;VTs&#8221;.</p>

<p>By pressing <kbd class="USERINPUT">Alt</kbd> and a function key, you can switch
between virtual terminals; each function key corresponds to one. Slackware has logins on
6 VTs by default. <b class="KEYCAP">Alt</b>+<b class="KEYCAP">F2</b> will take you to the
second one, <b class="KEYCAP">Alt</b>+<b class="KEYCAP">F3</b> to the third, etc.</p>

<p>The rest of the function keys are reserved for X sessions. Each X session uses its own
VT, beginning with the seventh (<b class="KEYCAP">Alt</b>+<b class="KEYCAP">F7</b>) and
going up. When in X, the <b class="KEYCAP">Alt</b>+<b class="KEYCAP">Function key</b>
combination is replaced with <b class="KEYCAP">Ctrl</b>+<b class="KEYCAP">Alt</b>+<b
class="KEYCAP">Function</b>; so if you are in X and want to get back to a text login
(without exiting your X session), <b class="KEYCAP">Ctrl</b>+<b class="KEYCAP">Alt</b>+<b
class="KEYCAP">F3</b> will take you to the third. (<b class="KEYCAP">Alt</b>+<b
class="KEYCAP">F7</b> will take you back, assuming you're using the first X session.)</p>

<div class="SECT2">
<h2 class="SECT2"><a id="AEN3024" name="AEN3024">8.4.1 Screen</a></h2>

<p>But what about situations where there are no virtual terminals? What then?
Fortunately, slackware includes a beautiful screen manager aptly named <tt
class="COMMAND">screen</tt>. <tt class="COMMAND">screen</tt> is a terminal emulator that
has virtual terminal like capabilities. Executing <tt class="COMMAND">screen</tt> flashes
a brief introduction, then dumps to a terminal. Unlike the standard virtual terminals,
<tt class="COMMAND">screen</tt> has its own commands. All <tt class="COMMAND">screen</tt>
commands are prefixed with a <b class="KEYCAP">Crtl</b>+<b class="KEYCAP">A</b>
keystroke. For example, <b class="KEYCAP">Ctrl</b>+<b class="KEYCAP">A</b>+<b
class="KEYCAP">C</b> will create a new terminal session. <b class="KEYCAP">Ctrl</b>+<b
class="KEYCAP">A</b>+<b class="KEYCAP">N</b> will switch to the next terminal. <b
class="KEYCAP">Ctrl</b>+<b class="KEYCAP">A</b>+<b class="KEYCAP">P</b> switches to the
previous terminal.</p>

<p><tt class="COMMAND">screen</tt> also supports detaching and re-attaching to <tt
class="COMMAND">screen</tt> sessions which is particularly useful for remote sessions via
<tt class="COMMAND">ssh</tt> and <tt class="COMMAND">telnet</tt>, (more on those later).
<b class="KEYCAP">Ctrl</b>+<b class="KEYCAP">A</b>+<b class="KEYCAP">D</b> will detach
from the currently running screen. Executing <tt class="COMMAND">screen -r</tt> will list
all currently running screen sessions you may reattach to.</p>

<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">screen -r</kbd>
There are several suitable screens on:
     1212.pts-1.redtail      (Detached)
     1195.pts-1.redtail      (Detached)
     1225.pts-1.redtail      (Detached)
     17146.pts-1.sanctuary   (Dead ???)
Remove dead screens with 'screen -wipe'.
Type "screen [-d] -r [pid.]tty.host" to resume one of them. 
</pre>
</td>
</tr>
</table>

<p>Running <tt class="COMMAND">screen -r 1212</tt> would reattach to the first screen
listed. I mentioned earlier how useful this was for remote sessions. If I were to login
to a remote slackware server via <tt class="COMMAND">ssh</tt>, and my connection was
severed by some chance occurrence such as a local power failure, whatever I was doing at
that moment would instantly perish, which can be a horrible thing for your server. Using
<tt class="COMMAND">screen</tt> prevents this by detaching my session if my connection is
dropped. Once my connection is restored, I can reattach to my screen session and resume
right where I left off.</p>
</div>
</div>

<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="shell-bash.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="filesystem-structure.html"
accesskey="N">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">The Bourne Again Shell (bash)</td>
<td width="34%" align="center" valign="top"><a href="shell.html"
accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Filesystem Structure</td>
</tr>
</table>
</div>
</body>
</html>