/[ddp]/manuals/trunk/quick-reference/debian-reference.raw.xml
ViewVC logotype

Contents of /manuals/trunk/quick-reference/debian-reference.raw.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9206 - (show annotations) (download) (as text)
Sun May 20 15:58:45 2012 UTC (12 months ago) by elmig-guest
File MIME type: text/xml
File size: 1457769 byte(s)
updated portuguese translation
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
3 <book lang="en">
4 <bookinfo>
5 <title>Debian Reference</title>
6 <author>
7 <personname>Osamu Aoki</personname>
8 </author>
9 <abstract>
10 <para>This book is free; you may redistribute it and/or modify it under the terms of the GNU General Public License of any version compliant to the Debian Free Software Guidelines (DFSG).</para>
11 </abstract>
12 <copyright>
13 <year>2007-2012</year>
14 <holder>Osamu Aoki</holder>
15 </copyright>
16 <legalnotice>
17 <para>This Debian Reference (v2) (@-@build-date@-@) is intended to provide a broad overview of the Debian system as a post-installation user's guide. It covers many aspects of system administration through shell-command examples for non-developers.</para>
18 </legalnotice>
19 </bookinfo>
20 <preface id="_preface">
21 <title>Preface</title>
22 <para>This <ulink url="http://www.debian.org/doc/manuals/debian-reference/">Debian Reference (version 2)</ulink> (@-@build-date@-@) is intended to provide a broad overview of Debian system administration as a post-installation user guide.</para>
23 <para>The target reader is someone who is willing to learn shell scripts but who is not ready to read all the C sources to figure out how the <ulink url="http://en.wikipedia.org/wiki/GNU">GNU</ulink>/<ulink url="http://en.wikipedia.org/wiki/Linux">Linux</ulink> system works.</para>
24 <section id="_disclaimer">
25 <title>Disclaimer</title>
26 <para>All warranties are disclaimed. All trademarks are property of their respective trademark owners.</para>
27 <para>The Debian system itself is a moving target. This makes its documentation difficult to be current and correct. Although the current unstable version of Debian system was used as the basis for writing this, some contents may be already outdated by the time you read this.</para>
28 <para>Please treat this document as the secondary reference. This document does not replace any authoritative guides. The author and contributors do not take responsibility for consequences of errors, omissions or ambiguity in this document.</para>
29 </section>
30 <section id="_what_is_debian">
31 <title>What is Debian</title>
32 <para>The <ulink url="http://www.debian.org">Debian Project</ulink> is an association of individuals who have made common cause to create a free operating system. It's distribution is characterized by the following.</para>
33 <itemizedlist>
34 <listitem>
35 <para>
36 Commitment to the software freedom: <ulink url="http://www.debian.org/social_contract">Debian Social Contract and Debian Free Software Guidelines (DFSG)</ulink>
37 </para>
38 </listitem>
39 <listitem>
40 <para>
41 Internet based distributed unpaid volunteer effort: <ulink url="http://www.debian.org">http://www.debian.org</ulink>
42 </para>
43 </listitem>
44 <listitem>
45 <para>
46 Large number of pre-compiled high quality softwares
47 </para>
48 </listitem>
49 <listitem>
50 <para>
51 Focus on stability and security with easy access to the security updates
52 </para>
53 </listitem>
54 <listitem>
55 <para>
56 Focus on smooth upgrade to latest softwares with <literal>unstable</literal> and <literal>testing</literal> archives
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 Large number of supported hardware architectures
62 </para>
63 </listitem>
64 </itemizedlist>
65 <para>Free Software pieces in Debian come from <ulink url="http://en.wikipedia.org/wiki/GNU">GNU</ulink>, <ulink url="http://en.wikipedia.org/wiki/Linux">Linux</ulink>, <ulink url="http://en.wikipedia.org/wiki/Berkeley_Software_Distribution">BSD</ulink>, <ulink url="http://en.wikipedia.org/wiki/X_Window_System">X</ulink>, <ulink url="http://en.wikipedia.org/wiki/Internet_Systems_Consortium">ISC</ulink>, <ulink url="http://en.wikipedia.org/wiki/Apache_Software_Foundation">Apache</ulink>, <ulink url="http://en.wikipedia.org/wiki/Ghostscript">Ghostscript</ulink>, <ulink url="http://en.wikipedia.org/wiki/Common_Unix_Printing_System">Common Unix Printing System </ulink>, <ulink url="http://en.wikipedia.org/wiki/Samba_(software)">Samba</ulink>, <ulink url="http://en.wikipedia.org/wiki/GNOME">GNOME</ulink>, <ulink url="http://en.wikipedia.org/wiki/KDE">KDE</ulink>, <ulink url="http://en.wikipedia.org/wiki/Mozilla">Mozilla</ulink>, <ulink url="http://en.wikipedia.org/wiki/OpenOffice.org">OpenOffice.org</ulink>, <ulink url="http://en.wikipedia.org/wiki/Vim_(text_editor)">Vim</ulink>, <ulink url="http://en.wikipedia.org/wiki/TeX">TeX</ulink>, <ulink url="http://en.wikipedia.org/wiki/LaTeX">LaTeX</ulink>, <ulink url="http://en.wikipedia.org/wiki/DocBook">DocBook</ulink>, <ulink url="http://en.wikipedia.org/wiki/Perl">Perl</ulink>, <ulink url="http://en.wikipedia.org/wiki/Python_(programming_language)">Python</ulink>, <ulink url="http://en.wikipedia.org/wiki/Tcl">Tcl</ulink>, <ulink url="http://en.wikipedia.org/wiki/Java_(programming_language)">Java</ulink>, <ulink url="http://en.wikipedia.org/wiki/Ruby_(programming_language)">Ruby</ulink>, <ulink url="http://en.wikipedia.org/wiki/PHP">PHP</ulink>, <ulink url="http://en.wikipedia.org/wiki/Berkeley_DB">Berkeley DB</ulink>, <ulink url="http://en.wikipedia.org/wiki/MySQL">MySQL</ulink>, <ulink url="http://en.wikipedia.org/wiki/PostgreSQL">PostgreSQL</ulink>, <ulink url="http://en.wikipedia.org/wiki/Exim">Exim</ulink>, <ulink url="http://en.wikipedia.org/wiki/Postfix_(software)">Postfix</ulink>, <ulink url="http://en.wikipedia.org/wiki/Mutt_(e-mail_client)">Mutt</ulink>, <ulink url="http://en.wikipedia.org/wiki/FreeBSD">FreeBSD</ulink>, <ulink url="http://en.wikipedia.org/wiki/OpenBSD">OpenBSD</ulink>, <ulink url="http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs">Plan 9</ulink> and many more independent free software projects. Debian integrates this diversity of Free Software into one system.</para>
66 </section>
67 <section id="_about_this_document">
68 <title>About this document</title>
69 <section id="_guiding_rules">
70 <title>Guiding rules</title>
71 <para>Following guiding rules are followed while compiling this document.</para>
72 <itemizedlist>
73 <listitem>
74 <para>
75 Provide overview and skip corner cases. (<emphasis role="strong">Big Picture</emphasis>)
76 </para>
77 </listitem>
78 <listitem>
79 <para>
80 Keep It Short and Simple. (<emphasis role="strong">KISS</emphasis>)
81 </para>
82 </listitem>
83 <listitem>
84 <para>
85 Do not reinvent the wheel. (Use pointers to <emphasis role="strong">the existing references</emphasis>)
86 </para>
87 </listitem>
88 <listitem>
89 <para>
90 Focus on non-GUI tools and consoles. (Use <emphasis role="strong">shell examples</emphasis>)
91 </para>
92 </listitem>
93 <listitem>
94 <para>
95 Be objective. (Use <ulink url="http://popcon.debian.org/">popcon</ulink> etc.)
96 </para>
97 </listitem>
98 </itemizedlist>
99 <tip>
100 <para>I tried to elucidate hierarchical aspects and lower levels of the system.</para>
101 </tip>
102 </section>
103 <section id="_prerequisites">
104 <title>Prerequisites</title>
105 <warning>
106 <para>You are expected to make good efforts to seek answers by yourself beyond this documentation. This document only gives efficient starting points.</para>
107 </warning>
108 <para>You must seek solution by yourself from primary sources.</para>
109 <itemizedlist>
110 <listitem>
111 <para>
112 The Debian site at <ulink url="http://www.debian.org">http://www.debian.org</ulink> for the general information
113 </para>
114 </listitem>
115 <listitem>
116 <para>
117 The documentation under the "<literal>/usr/share/doc/&lt;package_name&gt;</literal>" directory
118 </para>
119 </listitem>
120 <listitem>
121 <para>
122 The Unix style <emphasis role="strong">manpage</emphasis>: "<literal>dpkg -L &lt;package_name&gt; |grep '/man/man.*/'</literal>"
123 </para>
124 </listitem>
125 <listitem>
126 <para>
127 The GNU style <emphasis role="strong">info page</emphasis>: "<literal>dpkg -L &lt;package_name&gt; |grep '/info/'</literal>"
128 </para>
129 </listitem>
130 <listitem>
131 <para>
132 The bug report: <ulink url="http://bugs.debian.org/">http://bugs.debian.org/&lt;package_name&gt;</ulink>
133 </para>
134 </listitem>
135 <listitem>
136 <para>
137 The Debian Wiki at <ulink url="http://wiki.debian.org/">http://wiki.debian.org/</ulink> for the moving and specific topics
138 </para>
139 </listitem>
140 <listitem>
141 <para>
142 The HOWTOs from The Linux Documentation Project (TLDP) at <ulink url="http://tldp.org/">http://tldp.org/</ulink>
143 </para>
144 </listitem>
145 <listitem>
146 <para>
147 The Single UNIX Specification from the Open Group's The UNIX System Home Page at <ulink url="http://www.unix.org/">http://www.unix.org/</ulink>
148 </para>
149 </listitem>
150 <listitem>
151 <para>
152 The free encyclopedia from Wikipedia at <ulink url="http://www.wikipedia.org/">http://www.wikipedia.org/</ulink>
153 </para>
154 </listitem>
155 </itemizedlist>
156 <note>
157 <para>For detailed documentation, you may need to install the corresponding documentation package named with "<literal>-doc</literal>" as its suffix.</para>
158 </note>
159 </section>
160 <section id="_conventions">
161 <title>Conventions</title>
162 <para>This document provides information through the following simplified presentation style with <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry> shell command examples.</para>
163 <screen># &lt;command in root account&gt;
164 $ &lt;command in user account&gt;</screen>
165 <para>These shell prompts distinguish account used and correspond to set environment variables as: "<literal>PS1='\$'</literal>" and "<literal>PS2=' '</literal>". These values are chosen for the sake of readability of this document and are not typical on actual installed system.</para>
166 <note>
167 <para>See the meaning of the "<literal>$PS1</literal>" and "<literal>$PS2</literal>" environment variables in <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
168 </note>
169 <para><emphasis role="strong">Action</emphasis> required by the system administrator is written in the imperative sentence, e.g. "Type Enter-key after typing each command string to the shell."</para>
170 <para>The <emphasis role="strong">description</emphasis> column and similar ones in the table may contain a <emphasis role="strong">noun phrase</emphasis> following <ulink url="http://www.debian.org/doc/manuals/developers-reference/best-pkging-practices#bpp-desc-basics">the package short description convention</ulink> which drops leading articles such as "a" and "the". They may alternatively contain an infinitive phrase as a <emphasis role="strong">noun phrase</emphasis> without leading "to" following the short command description convention in manpages. These may look funny to some people but are my intentional choices of style to keep this documentation as simple as possible. These <emphasis role="strong">Noun phrases</emphasis> do not capitalize their starting nor end with periods following these short description convention.</para>
171 <note>
172 <para>Proper nouns including command names keeps their case irrespective of their location.</para>
173 </note>
174 <para>A <emphasis role="strong">command snippet</emphasis> quoted in a text paragraph is referred by the typewriter font between double quotation marks, such as "<literal>aptitude safe-upgrade</literal>".</para>
175 <para>A <emphasis role="strong">text data</emphasis> from a configuration file quoted in a text paragraph is referred by the typewriter font between double quotation marks, such as "<literal>deb-src</literal>".</para>
176 <para>A <emphasis role="strong">command</emphasis> is referred by its name in the typewriter font optionally followed by its manpage section number in parenthesis, such as <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry>. You are encouraged to obtain information by typing the following.</para>
177 <screen>$ man 1 bash</screen>
178 <para>A <emphasis role="strong">manpage</emphasis> is referred by its name in the typewriter font followed by its manpage section number in parenthesis, such as <citerefentry><refentrytitle>sources.list</refentrytitle><manvolnum>5</manvolnum></citerefentry>. You are encouraged to obtain information by typing the following.</para>
179 <screen>$ man 5 sources.list</screen>
180 <para>An <emphasis role="strong">info page</emphasis> is referred by its command snippet in the typewriter font between double quotation marks, such as "<literal>info make</literal>". You are encouraged to obtain information by typing the following.</para>
181 <screen>$ info make</screen>
182 <para>A <emphasis role="strong">filename</emphasis> is referred by the typewriter font between double quotation marks, such as "<literal>/etc/passwd</literal>". For configuration files, you are encouraged to obtain information by typing the following.</para>
183 <screen>$ sensible-pager "/etc/passwd"</screen>
184 <para>A <emphasis role="strong">directory name</emphasis> is referred by the typewriter font between double quotation marks, such as "<literal>/etc/init.d/</literal>". You are encouraged to explore its contents by typing the following.</para>
185 <screen>$ mc "/etc/init.d/"</screen>
186 <para>A <emphasis role="strong">package name</emphasis> is referred by its name in the typewriter font, such as <literal>vim</literal>. You are encouraged to obtain information by typing the following.</para>
187 <screen>$ dpkg -L vim
188 $ apt-cache show vim
189 $ aptitude show vim</screen>
190 <para>A <emphasis role="strong">documentation</emphasis> may indicate its location by the filename in the typewriter font between double quotation marks, such as "<literal>/usr/share/doc/sysv-rc/README.runlevels.gz</literal>" and "<literal>/usr/share/doc/base-passwd/users-and-groups.html</literal>"; or by its <ulink url="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL</ulink>, such as <ulink url="http://www.debian.org">http://www.debian.org</ulink>. You are encouraged to read the documentation by typing the following.</para>
191 <screen>$ zcat "/usr/share/doc/sysv-rc/README.runlevels.gz" | sensible-pager
192 $ sensible-browser "/usr/share/doc/base-passwd/users-and-groups.html"
193 $ sensible-browse "http://www.debian.org"</screen>
194 <para>An <emphasis role="strong">environment variable</emphasis> is referred by its name with leading "<literal>$</literal>" in the typewriter font between double quotation marks, such as "<literal>$TERM</literal>". You are encouraged to obtain its current value by typing the following.</para>
195 <screen>$ echo "$TERM"</screen>
196 </section>
197 <section id="_the_popcon">
198 <title>The popcon</title>
199 <para>The <ulink url="http://popcon.debian.org/">popcon</ulink> data is presented as the objective measure for the popularity of each package. It was downloaded on @-@pop-date@-@ and contains the total submission of @-@pop-submissions@-@ reports over @-@pop-packages@-@ binary packages and @-@pop-architectures@-@ architectures.</para>
200 <note>
201 <para>Please note that the <literal>@-@arch@-@</literal> <literal>unstable</literal> archive contains only @-@all-packages@-@ packages currently. The popcon data contains reports from many old system installations.</para>
202 </note>
203 <para>The popcon number preceded with "V:" for "votes" is calculated by "100 * (the popcon submissions for the package executed recently on the PC)/(the total popcon submissions)".</para>
204 <para>The popcon number preceded with "I:" for "installs" is calculated by "100 * (the popcon submissions for the package installed on the PC)/(the total popcon submissions)".</para>
205 <note>
206 <para>The popcon figures should not be considered as absolute measures of the importance of packages. There are many factors which can skew statistics. For example, some system participating popcon may have mounted directories such as "<literal>/bin</literal>" with "<literal>noatime</literal>" option for system performance improvement and effectively disabled "vote" from such system.</para>
207 </note>
208 </section>
209 <section id="_the_package_size">
210 <title>The package size</title>
211 <para>The package size data is also presented as the objective measure for each package. It is based on the "<literal>Installed-Size:</literal>" reported by "<literal>apt-cache show</literal>" or "<literal>aptitude show</literal>" command (currently on <literal>@-@arch@-@</literal> architecture for the <literal>unstable</literal> release). The reported size is in KiB (<ulink url="http://en.wikipedia.org/wiki/Kibibyte">Kibibyte</ulink> = unit for 1024 bytes).</para>
212 <note>
213 <para>A package with a small numerical package size may indicate that the package in the <literal>unstable</literal> release is a dummy package which installs other packages with significant contents by the dependency. The dummy package enables a smooth transition or split of the package.</para>
214 </note>
215 <note>
216 <para>A package size followed by "(*)" indicates that the package in the <literal>unstable</literal> release is missing and the package size for the <literal>experimental</literal> release is used instead.</para>
217 </note>
218 </section>
219 <section id="_bug_reports_on_this_document">
220 <title>Bug reports on this document</title>
221 <para>Please file bug reports on the <literal>debian-reference</literal> package using <citerefentry><refentrytitle>reportbug</refentrytitle><manvolnum>1</manvolnum></citerefentry> if you find any issues on this document. Please include correction suggestion by "<literal>diff -u</literal>" to the plain text version or to the source.</para>
222 </section>
223 </section>
224 <section id="_some_quotes_for_new_users">
225 <title>Some quotes for new users</title>
226 <para>Here are some interesting quotes from the Debian mailing list which may help enlighten new users.</para>
227 <itemizedlist>
228 <listitem>
229 <para>
230 "This is Unix. It gives you enough rope to hang yourself." --- Miquel van Smoorenburg <literal>&lt;miquels at cistron.nl&gt;</literal>
231 </para>
232 </listitem>
233 <listitem>
234 <para>
235 "Unix IS user friendly… It's just selective about who its friends are." --- Tollef Fog Heen <literal>&lt;tollef at add.no&gt;</literal>
236 </para>
237 </listitem>
238 </itemizedlist>
239 </section>
240 </preface>
241 <chapter id="_gnu_linux_tutorials">
242 <title>GNU/Linux tutorials</title>
243 <para>I think learning a computer system is like learning a new foreign language. Although tutorial books and documentation are helpful, you have to practice it yourself. In order to help you get started smoothly, I elaborate a few basic points.</para>
244 <para>The powerful design of <ulink url="http://www.debian.org">Debian</ulink> <ulink url="http://en.wikipedia.org/wiki/GNU">GNU</ulink>/<ulink url="http://en.wikipedia.org/wiki/Linux">Linux</ulink> comes from the <ulink url="http://en.wikipedia.org/wiki/Unix">Unix</ulink> operating system, i.e., a <ulink url="http://en.wikipedia.org/wiki/Multi-user">multiuser</ulink>, <ulink url="http://en.wikipedia.org/wiki/Computer_multitasking">multitasking</ulink> operating system. You must learn to take advantage of the power of these features and similarities between Unix and GNU/Linux.</para>
245 <para>Don't shy away from Unix oriented texts and don't rely solely on GNU/Linux texts, as this robs you of much useful information.</para>
246 <note>
247 <para>If you have been using any <ulink url="http://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> system for a while with command line tools, you probably know everything I explain here. Please use this as a reality check and refresher.</para>
248 </note>
249 <section id="_console_basics">
250 <title>Console basics</title>
251 <section id="_the_shell_prompt">
252 <title>The shell prompt</title>
253 <para>Upon starting the system, you are presented with the character based login screen if you did not install <ulink url="http://en.wikipedia.org/wiki/X_Window_System">X Window System</ulink> with the display manager such as <literal>gdm3</literal>. Suppose your hostname is <literal>foo</literal>, the login prompt looks as follows.</para>
254 <screen>foo login:</screen>
255 <para>If you did install a <ulink url="http://en.wikipedia.org/wiki/Graphical_user_interface">GUI</ulink> environment such as <ulink url="http://en.wikipedia.org/wiki/GNOME">GNOME</ulink> or <ulink url="http://en.wikipedia.org/wiki/KDE">KDE</ulink>, then you can get to a login prompt by Ctrl-Alt-F1, and you can return to the GUI environment via Alt-F7 (see <xref linkend="_virtual_consoles"/> below for more).</para>
256 <para>At the login prompt, you type your username, e.g. <literal>penguin</literal>, and press the Enter-key, then type your password and press the Enter-key again.</para>
257 <note>
258 <para>Following the Unix tradition, the username and password of the Debian system are case sensitive. The username is usually chosen only from the lowercase. The first user account is usually created during the installation. Additional user accounts can be created with <citerefentry><refentrytitle>adduser</refentrytitle><manvolnum>8</manvolnum></citerefentry> by root.</para>
259 </note>
260 <para>The system starts with the greeting message stored in "<literal>/etc/motd</literal>" (Message Of The Day) and presents a command prompt.</para>
261 <screen>Debian GNU/Linux lenny/sid foo tty1
262 foo login: penguin
263 Password:
264 Last login: Sun Apr 22 09:29:34 2007 on tty1
265 Linux snoopy 2.6.20-1-amd64 #1 SMP Sun Apr 15 20:25:49 UTC 2007 x86_64
266
267 The programs included with the Debian GNU/Linux system are free software;
268 the exact distribution terms for each program are described in the
269 individual files in /usr/share/doc/*/copyright.
270
271 Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
272 permitted by applicable law.
273 foo:~$</screen>
274 <para>Here, the main part of the greeting message can be customized by editing the "<literal>/etc/motd.tail</literal>" file. The first line is generated from the system information using "<literal>uname -snrvm</literal>".</para>
275 <para>Now you are in the <ulink url="http://en.wikipedia.org/wiki/Shell_(computing)">shell</ulink>. The shell interprets your commands.</para>
276 </section>
277 <section id="_the_shell_prompt_under_x">
278 <title>The shell prompt under X</title>
279 <para>If you installed <ulink url="http://en.wikipedia.org/wiki/X_Window_System">X Window System</ulink> with a display manager such as <ulink url="http://en.wikipedia.org/wiki/GNOME">GNOME</ulink>'s <literal>gdm3</literal> by selecting "Desktop environment" task during the installation, you are presented with the graphical login screen upon starting your system. You type your username and your password to login to the non-privileged user account. Use tab to navigate between username and password, or use the mouse and primary click.</para>
280 <para>You can gain the shell prompt under X by starting a <literal>x-terminal-emulator</literal> program such as <citerefentry><refentrytitle>gnome-terminal</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>rxvt</refentrytitle><manvolnum>1</manvolnum></citerefentry> or <citerefentry><refentrytitle>xterm</refentrytitle><manvolnum>1</manvolnum></citerefentry>. Under the GNOME Desktop environment, clicking "Applications" → "Accessories" → "Terminal" does the trick.</para>
281 <para>You can also see the section below <xref linkend="_virtual_consoles"/>.</para>
282 <para>Under some other Desktop systems (like <literal>fluxbox</literal>), there may be no obvious starting point for the menu. If this happens, just try (right) clicking the center of the screen and hope for a menu to pop-up.</para>
283 </section>
284 <section id="_the_root_account">
285 <title>The root account</title>
286 <para>The root account is also called <ulink url="http://en.wikipedia.org/wiki/Superuser">superuser</ulink> or privileged user. From this account, you can perform the following system administration tasks.</para>
287 <itemizedlist>
288 <listitem>
289 <para>
290 Read, write, and remove any files on the system irrespective of their file permissions
291 </para>
292 </listitem>
293 <listitem>
294 <para>
295 Set file ownership and permissions of any files on the system
296 </para>
297 </listitem>
298 <listitem>
299 <para>
300 Set the password of any non-privileged users on the system
301 </para>
302 </listitem>
303 <listitem>
304 <para>
305 Login to any accounts without their passwords
306 </para>
307 </listitem>
308 </itemizedlist>
309 <para>This unlimited power of root account requires you to be considerate and responsible when using it.</para>
310 <warning>
311 <para>Never share the root password with others.</para>
312 </warning>
313 <note>
314 <para>File permissions of a file (including hardware devices such as CD-ROM etc. which are just another file for the Debian system) may render it unusable or inaccessible by non-root users. Although the use of root account is a quick way to test this kind of situation, its resolution should be done through proper setting of file permissions and user's group membership (see <xref linkend="_filesystem_permissions"/>).</para>
315 </note>
316 </section>
317 <section id="_the_root_shell_prompt">
318 <title>The root shell prompt</title>
319 <para>Here are a few basic methods to gain the root shell prompt by using the root password.</para>
320 <itemizedlist>
321 <listitem>
322 <para>
323 Type <literal>root</literal> at the character based login prompt.
324 </para>
325 </listitem>
326 <listitem>
327 <para>
328 Click "Applications" → "Accessories" → "Root Terminal", under the GNOME Desktop environment.
329 </para>
330 </listitem>
331 <listitem>
332 <para>
333 Type "<literal>su -l</literal>" from any user shell prompt.
334 </para>
335 <itemizedlist>
336 <listitem>
337 <para>
338 This does not preserve the environment of the current user.
339 </para>
340 </listitem>
341 </itemizedlist>
342 </listitem>
343 <listitem>
344 <para>
345 Type "<literal>su</literal>" from any user shell prompt.
346 </para>
347 <itemizedlist>
348 <listitem>
349 <para>
350 This preserves some of the environment of the current user.
351 </para>
352 </listitem>
353 </itemizedlist>
354 </listitem>
355 </itemizedlist>
356 </section>
357 <section id="_gui_system_administration_tools">
358 <title>GUI system administration tools</title>
359 <para>When your desktop menu does not start GUI system administration tools automatically with the appropriate privilege, you can start them from the root shell prompt of the X terminal emulator, such as <citerefentry><refentrytitle>gnome-terminal</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>rxvt</refentrytitle><manvolnum>1</manvolnum></citerefentry>, or <citerefentry><refentrytitle>xterm</refentrytitle><manvolnum>1</manvolnum></citerefentry>. See <xref linkend="_the_root_shell_prompt"/> and <xref linkend="_running_x_clients_as_root"/>.</para>
360 <warning>
361 <para>Never start the X display/session manager under the root account by typing in <literal>root</literal> to the prompt of the display manager such as <citerefentry><refentrytitle>gdm3</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
362 </warning>
363 <warning>
364 <para>Never run untrusted remote GUI program under X Window when critical information is displayed since it may eavesdrop your X screen.</para>
365 </warning>
366 </section>
367 <section id="_virtual_consoles">
368 <title>Virtual consoles</title>
369 <para>In the default Debian system, there are six switchable <ulink url="http://en.wikipedia.org/wiki/VT100">VT100-like</ulink> character consoles available to start the command shell directly on the Linux host. Unless you are in a GUI environment, you can switch between the virtual consoles by pressing the <literal>Left-Alt-key</literal> and one of the <literal>F1</literal> — <literal>F6</literal> keys simultaneously. Each character console allows independent login to the account and offers the multiuser environment. This multiuser environment is a great Unix feature, and very addictive.</para>
370 <para>If you are under the X Window System, you gain access to the character console 1 by pressing <literal>Ctrl-Alt-F1</literal> key, i.e., the <literal>left-Ctrl-key</literal>, the <literal>left-Alt-key</literal>, and the <literal>F1-key</literal> are pressed together. You can get back to the X Window System, normally running on the virtual console 7, by pressing <literal>Alt-F7</literal>.</para>
371 <para>You can alternatively change to another virtual console, e.g. to the console 1, from the commandline.</para>
372 <screen># chvt 1</screen>
373 </section>
374 <section id="_how_to_leave_the_command_prompt">
375 <title>How to leave the command prompt</title>
376 <para>You type <literal>Ctrl-D</literal>, i.e., the <literal>left-Ctrl-key</literal> and the <literal>d-key</literal> pressed together, at the command prompt to close the shell activity. If you are at the character console, you return to the login prompt with this. Even though these control characters are referred as "control D" with the upper case, you do not need to press the Shift-key. The short hand expression, <literal>^D</literal>, is also used for <literal>Ctrl-D</literal>. Alternately, you can type "exit".</para>
377 <para>If you are at <citerefentry><refentrytitle>x-terminal-emulator</refentrytitle><manvolnum>1</manvolnum></citerefentry>, you can close <literal>x-terminal-emulator</literal> window with this.</para>
378 </section>
379 <section id="_how_to_shutdown_the_system">
380 <title>How to shutdown the system</title>
381 <para>Just like any other modern OS where the file operation involves <ulink url="http://en.wikipedia.org/wiki/Cache">caching data</ulink> in memory for improved performance, the Debian system needs the proper shutdown procedure before power can safely be turned off. This is to maintain the integrity of files, by forcing all changes in memory to be written to disk. If the software power control is available, the shutdown procedure automatically turns off power of the system. (Otherwise, you may have to press power button for few seconds after the shutdown procedure.)</para>
382 <para>You can shutdown the system under the normal multiuser mode from the commandline.</para>
383 <screen># shutdown -h now</screen>
384 <para>You can shutdown the system under the single-user mode from the commandline.</para>
385 <screen># poweroff -i -f</screen>
386 <para>Alternatively, you may type <literal>Ctrl-Alt-Delete</literal> (The <literal>left-Ctrl-key</literal>, the <literal>left-Alt-Key</literal>, and the <literal>Delete</literal> are pressed together) to shutdown if "<literal>/etc/inittab</literal>" contains "<literal>ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now</literal>" in it. See <citerefentry><refentrytitle>inittab</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details.</para>
387 <para>See <xref linkend="_how_to_shutdown_the_remote_system_on_ssh"/>.</para>
388 </section>
389 <section id="_recovering_a_sane_console">
390 <title>Recovering a sane console</title>
391 <para>When the screen goes berserk after doing some funny things such as "<literal>cat &lt;some-binary-file&gt;</literal>", type "<literal>reset</literal>" at the command prompt. You may not be able to see the command echoed as you type. You may also issue "<literal>clear</literal>" to clean up the screen.</para>
392 </section>
393 <section id="_additional_package_suggestions_for_the_newbie">
394 <title>Additional package suggestions for the newbie</title>
395 <para>Although even the minimal installation of the Debian system without any desktop environment tasks provides the basic Unix functionality, it is a good idea to install few additional commandline and curses based character terminal packages such as <literal>mc</literal> and <literal>vim</literal> with <citerefentry><refentrytitle>apt-get</refentrytitle><manvolnum>8</manvolnum></citerefentry> for beginners to get started by the following.</para>
396 <screen># apt-get update
397 ...
398 # apt-get install mc vim sudo
399 ...</screen>
400 <para>If you already had these packages installed, no new packages are installed.</para>
401 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
402 <title>List of interesting text-mode program packages</title>
403 <tgroup cols="4">
404 <colspec colwidth="59pt" align="left"/>
405 <colspec colwidth="76pt" align="left"/>
406 <colspec colwidth="70pt" align="left"/>
407 <colspec colwidth="407pt" align="left"/>
408 <thead>
409 <row>
410 <entry>
411 package
412 </entry>
413 <entry>
414 popcon
415 </entry>
416 <entry>
417 size
418 </entry>
419 <entry>
420 description
421 </entry>
422 </row>
423 </thead>
424 <tbody>
425 <row>
426 <entry>
427 <literal>mc</literal>
428 </entry>
429 <entry>
430 @-@popcon1@-@
431 </entry>
432 <entry>
433 @-@psize1@-@
434 </entry>
435 <entry>
436 A text-mode full-screen file manager
437 </entry>
438 </row>
439 <row>
440 <entry>
441 <literal>sudo</literal>
442 </entry>
443 <entry>
444 @-@popcon1@-@
445 </entry>
446 <entry>
447 @-@psize1@-@
448 </entry>
449 <entry>
450 A program to allow limited root privileges to users
451 </entry>
452 </row>
453 <row>
454 <entry>
455 <literal>vim</literal>
456 </entry>
457 <entry>
458 @-@popcon1@-@
459 </entry>
460 <entry>
461 @-@psize1@-@
462 </entry>
463 <entry>
464 Unix text editor Vi IMproved, a programmers text editor (standard version)
465 </entry>
466 </row>
467 <row>
468 <entry>
469 <literal>vim-tiny</literal>
470 </entry>
471 <entry>
472 @-@popcon1@-@
473 </entry>
474 <entry>
475 @-@psize1@-@
476 </entry>
477 <entry>
478 Unix text editor Vi IMproved, a programmers text editor (compact version)
479 </entry>
480 </row>
481 <row>
482 <entry>
483 <literal>emacs23</literal>
484 </entry>
485 <entry>
486 @-@popcon1@-@
487 </entry>
488 <entry>
489 @-@psize1@-@
490 </entry>
491 <entry>
492 GNU project Emacs, the Lisp based extensible text editor (version 23)
493 </entry>
494 </row>
495 <row>
496 <entry>
497 <literal>w3m</literal>
498 </entry>
499 <entry>
500 @-@popcon1@-@
501 </entry>
502 <entry>
503 @-@psize1@-@
504 </entry>
505 <entry>
506 Text-mode WWW browsers
507 </entry>
508 </row>
509 <row>
510 <entry>
511 <literal>gpm</literal>
512 </entry>
513 <entry>
514 @-@popcon1@-@
515 </entry>
516 <entry>
517 @-@psize1@-@
518 </entry>
519 <entry>
520 The Unix style cut-and-paste on the text console (daemon)
521 </entry>
522 </row>
523 </tbody>
524 </tgroup>
525 </table>
526 <para>It may be a good idea to read some informative documentations.</para>
527 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
528 <title>List of informative documentation packages</title>
529 <tgroup cols="4">
530 <colspec colwidth="124pt" align="left"/>
531 <colspec colwidth="76pt" align="left"/>
532 <colspec colwidth="70pt" align="left"/>
533 <colspec colwidth="342pt" align="left"/>
534 <thead>
535 <row>
536 <entry>
537 package
538 </entry>
539 <entry>
540 popcon
541 </entry>
542 <entry>
543 size
544 </entry>
545 <entry>
546 description
547 </entry>
548 </row>
549 </thead>
550 <tbody>
551 <row>
552 <entry>
553 <literal>doc-debian</literal>
554 </entry>
555 <entry>
556 @-@popcon1@-@
557 </entry>
558 <entry>
559 @-@psize1@-@
560 </entry>
561 <entry>
562 Debian Project documentation, (Debian FAQ) and other documents
563 </entry>
564 </row>
565 <row>
566 <entry>
567 <literal>debian-policy</literal>
568 </entry>
569 <entry>
570 @-@popcon1@-@
571 </entry>
572 <entry>
573 @-@psize1@-@
574 </entry>
575 <entry>
576 Debian Policy Manual and related documents
577 </entry>
578 </row>
579 <row>
580 <entry>
581 <literal>developers-reference</literal>
582 </entry>
583 <entry>
584 @-@popcon1@-@
585 </entry>
586 <entry>
587 @-@psize1@-@
588 </entry>
589 <entry>
590 Guidelines and information for Debian developers
591 </entry>
592 </row>
593 <row>
594 <entry>
595 <literal>maint-guide</literal>
596 </entry>
597 <entry>
598 @-@popcon1@-@
599 </entry>
600 <entry>
601 @-@psize1@-@
602 </entry>
603 <entry>
604 Debian New Maintainers' Guide
605 </entry>
606 </row>
607 <row>
608 <entry>
609 <literal>debian-history</literal>
610 </entry>
611 <entry>
612 @-@popcon1@-@
613 </entry>
614 <entry>
615 @-@psize1@-@
616 </entry>
617 <entry>
618 History of the Debian Project
619 </entry>
620 </row>
621 <row>
622 <entry>
623 <literal>debian-faq</literal>
624 </entry>
625 <entry>
626 @-@popcon1@-@
627 </entry>
628 <entry>
629 @-@psize1@-@
630 </entry>
631 <entry>
632 Debian FAQ
633 </entry>
634 </row>
635 <row>
636 <entry>
637 <literal>doc-linux-text</literal>
638 </entry>
639 <entry>
640 @-@popcon1@-@
641 </entry>
642 <entry>
643 @-@psize1@-@
644 </entry>
645 <entry>
646 Linux HOWTOs and FAQ (text)
647 </entry>
648 </row>
649 <row>
650 <entry>
651 <literal>doc-linux-html</literal>
652 </entry>
653 <entry>
654 @-@popcon1@-@
655 </entry>
656 <entry>
657 @-@psize1@-@
658 </entry>
659 <entry>
660 Linux HOWTOs and FAQ (html)
661 </entry>
662 </row>
663 <row>
664 <entry>
665 <literal>sysadmin-guide</literal>
666 </entry>
667 <entry>
668 @-@popcon1@-@
669 </entry>
670 <entry>
671 @-@psize1@-@
672 </entry>
673 <entry>
674 The Linux System Administrators' Guide
675 </entry>
676 </row>
677 </tbody>
678 </tgroup>
679 </table>
680 <para>You can install some of these packages by the following.</para>
681 <screen># apt-get install package_name</screen>
682 </section>
683 <section id="_an_extra_user_account">
684 <title>An extra user account</title>
685 <para>If you do not want to use your main user account for the following training activities, you can create a training user account, e.g. <literal>fish</literal> by the following.</para>
686 <screen># adduser fish</screen>
687 <para>Answer all questions.</para>
688 <para>This creates a new account named as <literal>fish</literal>. After your practice, you can remove this user account and its home directory by the following.</para>
689 <screen># deluser --remove-home fish</screen>
690 </section>
691 <section id="_sudo_configuration">
692 <title>sudo configuration</title>
693 <para>For the typical single user workstation such as the desktop Debian system on the laptop PC, it is common to deploy simple configuration of <citerefentry><refentrytitle>sudo</refentrytitle><manvolnum>8</manvolnum></citerefentry> as follows to let the non-privileged user, e.g. <literal>penguin</literal>, to gain administrative privilege just with his user password but without the root password.</para>
694 <screen># echo "penguin ALL=(ALL) ALL" &gt;&gt; /etc/sudoers</screen>
695 <para>Alternatively, it is also common to do as follows to let the non-privileged user, e.g. <literal>penguin</literal>, to gain administrative privilege without any password.</para>
696 <screen># echo "penguin ALL=(ALL) NOPASSWD:ALL" &gt;&gt; /etc/sudoers</screen>
697 <para>This trick should only be used for the single user workstation which you administer and where you are the only user.</para>
698 <warning>
699 <para>Do not set up accounts of regular users on multiuser workstation like this because it would be very bad for system security.</para>
700 </warning>
701 <caution>
702 <para>The password and the account of the <literal>penguin</literal> in the above example requires as much protection as the root password and the root account.</para>
703 </caution>
704 <caution>
705 <para>Administrative privilege in this context belongs to someone authorized to perform the system administration task on the workstation. Never give some manager in the Admin department of your company or your boss such privilege unless they are authorized and capable.</para>
706 </caution>
707 <note>
708 <para>For providing access privilege to limited devices and limited files, you should consider to use <emphasis role="strong">group</emphasis> to provide limited access instead of using the <literal>root</literal> privilege via <citerefentry><refentrytitle>sudo</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
709 </note>
710 <note>
711 <para>With more thoughtful and careful configuration, <citerefentry><refentrytitle>sudo</refentrytitle><manvolnum>8</manvolnum></citerefentry> can grant limited administrative privileges to other users on a shared system without sharing the root password. This can help with accountability with hosts with multiple administrators so you can tell who did what. On the other hand, you might not want anyone else to have such privileges.</para>
712 </note>
713 </section>
714 <section id="_play_time">
715 <title>Play time</title>
716 <para>Now you are ready to play with the Debian system without risks as long as you use the non-privileged user account.</para>
717 <para>This is because the Debian system is, even after the default installation, configured with proper file permissions which prevent non-privileged users from damaging the system. Of course, there may still be some holes which can be exploited but those who worry about these issues should not be reading this section but should be reading <ulink url="http://www.debian.org/doc/manuals/securing-debian-howto/">Securing Debian Manual</ulink>.</para>
718 <para>We learn the Debian system as a <ulink url="http://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> system with the following.</para>
719 <itemizedlist>
720 <listitem>
721 <para><xref linkend="_unix_like_filesystem"/> (basic concept)
722 </para>
723 </listitem>
724 <listitem>
725 <para><xref linkend="_midnight_commander_mc"/> (survival method)
726 </para>
727 </listitem>
728 <listitem>
729 <para><xref linkend="_the_basic_unix_like_work_environment"/> (basic method)
730 </para>
731 </listitem>
732 <listitem>
733 <para><xref linkend="_the_simple_shell_command"/> (shell mechanism)
734 </para>
735 </listitem>
736 <listitem>
737 <para><xref linkend="_unix_like_text_processing"/> (text processing method)
738 </para>
739 </listitem>
740 </itemizedlist>
741 </section>
742 </section>
743 <section id="_unix_like_filesystem">
744 <title>Unix-like filesystem</title>
745 <para>In GNU/Linux and other <ulink url="http://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> operating systems, <ulink url="http://en.wikipedia.org/wiki/Computer_file">files</ulink> are organized into <ulink url="http://en.wikipedia.org/wiki/Directory_(file_systems)">directories</ulink>. All files and directories are arranged in one big tree rooted at "<literal>/</literal>". It's called a tree because if you draw the filesystem, it looks like a tree but it is upside down.</para>
746 <para>These files and directories can be spread out over several devices. <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> serves to attach the filesystem found on some device to the big file tree. Conversely, <citerefentry><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry> detaches it again. On recent Linux kernels, <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> with some options can bind part of a file tree somewhere else or can mount filesystem as shared, private, slave, or unbindable. Supported mount options for each filesystem are available in "<literal>/share/doc/linux-doc-2.6.*/Documentation/filesystems/</literal>".</para>
747 <para><emphasis role="strong">Directories</emphasis> on Unix systems are called <emphasis role="strong">folders</emphasis> on some other systems. Please also note that there is no concept for <emphasis role="strong">drive</emphasis> such as "<literal>A:</literal>" on any Unix system. There is one filesystem, and everything is included. This is a huge advantage compared to Windows.</para>
748 <section id="_unix_file_basics">
749 <title>Unix file basics</title>
750 <para>Here are some Unix file basics.</para>
751 <itemizedlist>
752 <listitem>
753 <para>
754 Filenames are <emphasis role="strong">case sensitive</emphasis>. That is, "<literal>MYFILE</literal>" and "<literal>MyFile</literal>" are different files.
755 </para>
756 </listitem>
757 <listitem>
758 <para>
759 The <emphasis role="strong">root directory</emphasis> means root of the filesystem referred as simply "<literal>/</literal>". Don't confuse this with the home directory for the root user: "<literal>/root</literal>".
760 </para>
761 </listitem>
762 <listitem>
763 <para>
764 Every directory has a name which can contain any letters or symbols <emphasis role="strong">except "<literal>/</literal>"</emphasis>. The root directory is an exception; its name is "<literal>/</literal>" (pronounced "slash" or "the root directory") and it cannot be renamed.
765 </para>
766 </listitem>
767 <listitem>
768 <para>
769 Each file or directory is designated by a <emphasis role="strong">fully-qualified filename</emphasis>, <emphasis role="strong">absolute filename</emphasis>, or <emphasis role="strong">path</emphasis>, giving the sequence of directories which must be passed through to reach it. The three terms are synonymous.
770 </para>
771 </listitem>
772 <listitem>
773 <para>
774 All <emphasis role="strong">fully-qualified filenames</emphasis> begin with the "<literal>/</literal>" directory, and there's a "<literal>/</literal>" between each directory or file in the filename. The first "<literal>/</literal>" is the top level directory, and the other "<literal>/</literal>"'s separate successive subdirectories, until we reach the last entry which is the name of the actual file. The words used here can be confusing. Take the following <emphasis role="strong">fully-qualified filename</emphasis> as an example: "<literal>/usr/share/keytables/us.map.gz</literal>". However, people also refers to its basename "<literal>us.map.gz</literal>" alone as a filename.
775 </para>
776 </listitem>
777 <listitem>
778 <para>
779 The root directory has a number of branches, such as "<literal>/etc/</literal>" and "<literal>/usr/</literal>". These subdirectories in turn branch into still more subdirectories, such as "<literal>/etc/init.d/</literal>" and "<literal>/usr/local/</literal>". The whole thing viewed collectively is called the <emphasis role="strong">directory tree</emphasis>. You can think of an absolute filename as a route from the base of the tree ("<literal>/</literal>") to the end of some branch (a file). You also hear people talk about the directory tree as if it were a <emphasis role="strong">family</emphasis> tree encompassing all direct descendants of a single figure called the root directory ("<literal>/</literal>"): thus subdirectories have <emphasis role="strong">parents</emphasis>, and a path shows the complete ancestry of a file. There are also relative paths that begin somewhere other than the root directory. You should remember that the directory "<literal>../</literal>" refers to the parent directory. This terminology also applies to other directory like structures, such as hierarchical data structures.
780 </para>
781 </listitem>
782 <listitem>
783 <para>
784 There's no special directory path name component that corresponds to a physical device, such as your hard disk. This differs from <ulink url="http://en.wikipedia.org/wiki/RT-11">RT-11</ulink>, <ulink url="http://en.wikipedia.org/wiki/CP/M">CP/M</ulink>, <ulink url="http://en.wikipedia.org/wiki/OpenVMS">OpenVMS</ulink>, <ulink url="http://en.wikipedia.org/wiki/MS-DOS">MS-DOS</ulink>, <ulink url="http://en.wikipedia.org/wiki/AmigaOS">AmigaOS</ulink>, and <ulink url="http://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</ulink>, where the path contains a device name such as "<literal>C:\</literal>". (However, directory entries do exist that refer to physical devices as a part of the normal filesystem. See <xref linkend="_filesystem_internals"/>.)
785 </para>
786 </listitem>
787 </itemizedlist>
788 <note>
789 <para>While you <emphasis role="strong">can</emphasis> use almost any letters or symbols in a file name, in practice it is a bad idea to do so. It is better to avoid any characters that often have special meanings on the command line, including spaces, tabs, newlines, and other special characters: <literal>{ } ( ) [ ] ' ` " \ / &gt; &lt; | ; ! # &amp; ^ * % @ $</literal> . If you want to separate words in a name, good choices are the period, hyphen, and underscore. You could also capitalize each word, "<literal>LikeThis</literal>". Experienced Linux users tend to avoid spaces in filenames.</para>
790 </note>
791 <note>
792 <para>The word "root" can mean either "root user" or "root directory". The context of their usage should make it clear.</para>
793 </note>
794 <note>
795 <para>The word <emphasis role="strong">path</emphasis> is used not only for <emphasis role="strong">fully-qualified filename</emphasis> as above but also for the <emphasis role="strong">command search path</emphasis>. The intended meaning is usually clear from the context.</para>
796 </note>
797 <para>The detailed best practices for the file hierarchy are described in the Filesystem Hierarchy Standard ("<literal>/usr/share/doc/debian-policy/fhs/fhs-2.3.txt.gz</literal>" and <citerefentry><refentrytitle>hier</refentrytitle><manvolnum>7</manvolnum></citerefentry>). You should remember the following facts as the starter.</para>
798 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
799 <title>List of usage of key directories</title>
800 <tgroup cols="2">
801 <colspec colwidth="65pt" align="left"/>
802 <colspec colwidth="499pt" align="left"/>
803 <thead>
804 <row>
805 <entry>
806 directory
807 </entry>
808 <entry>
809 usage of the directory
810 </entry>
811 </row>
812 </thead>
813 <tbody>
814 <row>
815 <entry>
816 <literal>/</literal>
817 </entry>
818 <entry>
819 the root directory
820 </entry>
821 </row>
822 <row>
823 <entry>
824 <literal>/etc/</literal>
825 </entry>
826 <entry>
827 system wide configuration files
828 </entry>
829 </row>
830 <row>
831 <entry>
832 <literal>/var/log/</literal>
833 </entry>
834 <entry>
835 system log files
836 </entry>
837 </row>
838 <row>
839 <entry>
840 <literal>/home/</literal>
841 </entry>
842 <entry>
843 all the home directories for all non-privileged users
844 </entry>
845 </row>
846 </tbody>
847 </tgroup>
848 </table>
849 </section>
850 <section id="_filesystem_internals">
851 <title>Filesystem internals</title>
852 <para>Following the <emphasis role="strong">Unix tradition</emphasis>, the Debian GNU/Linux system provides the <ulink url="http://en.wikipedia.org/wiki/File_system">filesystem</ulink> under which physical data on hard disks and other storage devices reside, and the interaction with the hardware devices such as console screens and remote serial consoles are represented in an unified manner under "<literal>/dev/</literal>".</para>
853 <para>Each file, directory, named pipe (a way two programs can share data), or physical device on a Debian GNU/Linux system has a data structure called an <ulink url="http://en.wikipedia.org/wiki/Inode">inode</ulink> which describes its associated attributes such as the user who owns it (owner), the group that it belongs to, the time last accessed, etc. If you are really interested, see "<literal>/usr/include/linux/fs.h</literal>" for the exact definition of "<literal>struct inode</literal>" in the Debian GNU/Linux system. The idea of representing just about everything in the filesystem was a Unix innovation, and modern Linux kernels have developed this idea ever further. Now, even information about processes running in the computer can be found in the filesystem.</para>
854 <para>This abstract and unified representation of physical entities and internal processes is very powerful since this allows us to use the same command for the same kind of operation on many totally different devices. It is even possible to change the way the kernel works by writing data to special files that are linked to running processes.</para>
855 <tip>
856 <para>If you need to identify the correspondence between the file tree and the physical entity, execute <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> with no arguments.</para>
857 </tip>
858 </section>
859 <section id="_filesystem_permissions">
860 <title>Filesystem permissions</title>
861 <para><ulink url="http://en.wikipedia.org/wiki/File_system_permissions">Filesystem permissions</ulink> of <ulink url="http://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> system are defined for three categories of affected users.</para>
862 <itemizedlist>
863 <listitem>
864 <para>
865 The <emphasis role="strong">user</emphasis> who owns the file (<emphasis role="strong">u</emphasis>)
866 </para>
867 </listitem>
868 <listitem>
869 <para>
870 Other users in the <emphasis role="strong">group</emphasis> which the file belongs to (<emphasis role="strong">g</emphasis>)
871 </para>
872 </listitem>
873 <listitem>
874 <para>
875 All <emphasis role="strong">other</emphasis> users (<emphasis role="strong">o</emphasis>) also referred to as "world" and "everyone"
876 </para>
877 </listitem>
878 </itemizedlist>
879 <para>For the file, each corresponding permission allows following actions.</para>
880 <itemizedlist>
881 <listitem>
882 <para>
883 The <emphasis role="strong">read</emphasis> (<emphasis role="strong">r</emphasis>) permission allows owner to examine contents of the file.
884 </para>
885 </listitem>
886 <listitem>
887 <para>
888 The <emphasis role="strong">write</emphasis> (<emphasis role="strong">w</emphasis>) permission allows owner to modify the file.
889 </para>
890 </listitem>
891 <listitem>
892 <para>
893 The <emphasis role="strong">execute</emphasis> (<emphasis role="strong">x</emphasis>) permission allows owner to run the file as a command.
894 </para>
895 </listitem>
896 </itemizedlist>
897 <para>For the directory, each corresponding permission allows following actions.</para>
898 <itemizedlist>
899 <listitem>
900 <para>
901 The <emphasis role="strong">read</emphasis> (<emphasis role="strong">r</emphasis>) permission allows owner to list contents of the directory.
902 </para>
903 </listitem>
904 <listitem>
905 <para>
906 The <emphasis role="strong">write</emphasis> (<emphasis role="strong">w</emphasis>) permission allows owner to add or remove files in the directory.
907 </para>
908 </listitem>
909 <listitem>
910 <para>
911 The <emphasis role="strong">execute</emphasis> (<emphasis role="strong">x</emphasis>) permission allows owner to access files in the directory.
912 </para>
913 </listitem>
914 </itemizedlist>
915 <para>Here, the <emphasis role="strong">execute</emphasis> permission on a directory means not only to allow reading of files in that directory but also to allow viewing their attributes, such as the size and the modification time.</para>
916 <para><citerefentry><refentrytitle>ls</refentrytitle><manvolnum>1</manvolnum></citerefentry> is used to display permission information (and more) for files and directories. When it is invoked with the "<literal>-l</literal>" option, it displays the following information in the order given.</para>
917 <itemizedlist>
918 <listitem>
919 <para><emphasis role="strong">Type of file</emphasis> (first character)
920 </para>
921 </listitem>
922 <listitem>
923 <para>
924 Access <emphasis role="strong">permission</emphasis> of the file (nine characters, consisting of three characters each for user, group, and other in this order)
925 </para>
926 </listitem>
927 <listitem>
928 <para><emphasis role="strong">Number of hard links</emphasis> to the file
929 </para>
930 </listitem>
931 <listitem>
932 <para>
933 Name of the <emphasis role="strong">user</emphasis> who owns the file
934 </para>
935 </listitem>
936 <listitem>
937 <para>
938 Name of the <emphasis role="strong">group</emphasis> which the file belongs to
939 </para>
940 </listitem>
941 <listitem>
942 <para><emphasis role="strong">Size</emphasis> of the file in characters (bytes)
943 </para>
944 </listitem>
945 <listitem>
946 <para><emphasis role="strong">Date and time</emphasis> of the file (mtime)
947 </para>
948 </listitem>
949 <listitem>
950 <para><emphasis role="strong">Name</emphasis> of the file
951 </para>
952 </listitem>
953 </itemizedlist>
954 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
955 <title>List of the first character of "<literal>ls -l</literal>" output</title>
956 <tgroup cols="2">
957 <colspec colwidth="54pt" align="left"/>
958 <colspec colwidth="119pt" align="left"/>
959 <thead>
960 <row>
961 <entry>
962 character
963 </entry>
964 <entry>
965 meaning
966 </entry>
967 </row>
968 </thead>
969 <tbody>
970 <row>
971 <entry>
972 <literal>-</literal>
973 </entry>
974 <entry>
975 normal file
976 </entry>
977 </row>
978 <row>
979 <entry>
980 <literal>d</literal>
981 </entry>
982 <entry>
983 directory
984 </entry>
985 </row>
986 <row>
987 <entry>
988 <literal>l</literal>
989 </entry>
990 <entry>
991 symlink
992 </entry>
993 </row>
994 <row>
995 <entry>
996 <literal>c</literal>
997 </entry>
998 <entry>
999 character device node
1000 </entry>
1001 </row>
1002 <row>
1003 <entry>
1004 <literal>b</literal>
1005 </entry>
1006 <entry>
1007 block device node
1008 </entry>
1009 </row>
1010 <row>
1011 <entry>
1012 <literal>p</literal>
1013 </entry>
1014 <entry>
1015 named pipe
1016 </entry>
1017 </row>
1018 <row>
1019 <entry>
1020 <literal>s</literal>
1021 </entry>
1022 <entry>
1023 socket
1024 </entry>
1025 </row>
1026 </tbody>
1027 </tgroup>
1028 </table>
1029 <para><citerefentry><refentrytitle>chown</refentrytitle><manvolnum>1</manvolnum></citerefentry> is used from the root account to change the owner of the file. <citerefentry><refentrytitle>chgrp</refentrytitle><manvolnum>1</manvolnum></citerefentry> is used from the file's owner or root account to change the group of the file. <citerefentry><refentrytitle>chmod</refentrytitle><manvolnum>1</manvolnum></citerefentry> is used from the file's owner or root account to change file and directory access permissions. Basic syntax to manipulate a <literal>foo</literal> file is the following.</para>
1030 <screen># chown &lt;newowner&gt; foo
1031 # chgrp &lt;newgroup&gt; foo
1032 # chmod [ugoa][+-=][rwxXst][,...] foo</screen>
1033 <para>For example, you can make a directory tree to be owned by a user <literal>foo</literal> and shared by a group <literal>bar</literal> by the following.</para>
1034 <screen># cd /some/location/
1035 # chown -R foo:bar .
1036 # chmod -R ug+rwX,o=rX .</screen>
1037 <para>There are three more special permission bits.</para>
1038 <itemizedlist>
1039 <listitem>
1040 <para>
1041 The <emphasis role="strong">set user ID</emphasis> bit (<emphasis role="strong">s</emphasis> or <emphasis role="strong">S</emphasis> instead of user's <emphasis role="strong">x</emphasis>)
1042 </para>
1043 </listitem>
1044 <listitem>
1045 <para>
1046 The <emphasis role="strong">set group ID</emphasis> bit (<emphasis role="strong">s</emphasis> or <emphasis role="strong">S</emphasis> instead of group's <emphasis role="strong">x</emphasis>)
1047 </para>
1048 </listitem>
1049 <listitem>
1050 <para>
1051 The <emphasis role="strong">sticky</emphasis> bit (<emphasis role="strong">t</emphasis> or <emphasis role="strong">T</emphasis> instead of other's <emphasis role="strong">x</emphasis>)
1052 </para>
1053 </listitem>
1054 </itemizedlist>
1055 <para>Here the output of "<literal>ls -l</literal>" for these bits is <emphasis role="strong">capitalized</emphasis> if execution bits hidden by these outputs are <emphasis role="strong">unset</emphasis>.</para>
1056 <para>Setting <emphasis role="strong">set user ID</emphasis> on an executable file allows a user to execute the executable file with the owner ID of the file (for example <emphasis role="strong">root</emphasis>). Similarly, setting <emphasis role="strong">set group ID</emphasis> on an executable file allows a user to execute the executable file with the group ID of the file (for example <emphasis role="strong">root</emphasis>). Because these settings can cause security risks, enabling them requires extra caution.</para>
1057 <para>Setting <emphasis role="strong">set group ID</emphasis> on a directory enables the <ulink url="http://en.wikipedia.org/wiki/Berkeley_Software_Distribution">BSD-like</ulink> file creation scheme where all files created in the directory belong to the <emphasis role="strong">group</emphasis> of the directory.</para>
1058 <para>Setting the <emphasis role="strong">sticky bit</emphasis> on a directory prevents a file in the directory from being removed by a user who is not the owner of the file. In order to secure contents of a file in world-writable directories such as "<literal>/tmp</literal>" or in group-writable directories, one must not only reset the <emphasis role="strong">write</emphasis> permission for the file but also set the <emphasis role="strong">sticky bit</emphasis> on the directory. Otherwise, the file can be removed and a new file can be created with the same name by any user who has write access to the directory.</para>
1059 <para>Here are a few interesting examples of file permissions.</para>
1060 <screen>$ ls -l /etc/passwd /etc/shadow /dev/ppp /usr/sbin/exim4
1061 crw------- 1 root root 108, 0 2007-04-29 07:00 /dev/ppp
1062 -rw-r--r-- 1 root root 1427 2007-04-16 00:19 /etc/passwd
1063 -rw-r----- 1 root shadow 943 2007-04-16 00:19 /etc/shadow
1064 -rwsr-xr-x 1 root root 700056 2007-04-22 05:29 /usr/sbin/exim4
1065 $ ls -ld /tmp /var/tmp /usr/local /var/mail /usr/src
1066 drwxrwxrwt 10 root root 4096 2007-04-29 07:59 /tmp
1067 drwxrwsr-x 10 root staff 4096 2007-03-24 18:48 /usr/local
1068 drwxrwsr-x 4 root src 4096 2007-04-27 00:31 /usr/src
1069 drwxrwsr-x 2 root mail 4096 2007-03-28 23:33 /var/mail
1070 drwxrwxrwt 2 root root 4096 2007-04-29 07:11 /var/tmp</screen>
1071 <para>There is an alternative numeric mode to describe file permissions with <citerefentry><refentrytitle>chmod</refentrytitle><manvolnum>1</manvolnum></citerefentry>. This numeric mode uses 3 to 4 digit wide octal (radix=8) numbers.</para>
1072 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1073 <title>The numeric mode for file permissions in <citerefentry><refentrytitle>chmod</refentrytitle><manvolnum>1</manvolnum></citerefentry> commands</title>
1074 <tgroup cols="2">
1075 <colspec colwidth="103pt" align="left"/>
1076 <colspec colwidth="456pt" align="left"/>
1077 <thead>
1078 <row>
1079 <entry>
1080 digit
1081 </entry>
1082 <entry>
1083 meaning
1084 </entry>
1085 </row>
1086 </thead>
1087 <tbody>
1088 <row>
1089 <entry>
1090 1st optional digit
1091 </entry>
1092 <entry>
1093 sum of <emphasis role="strong">set user ID</emphasis> (=4), <emphasis role="strong">set group ID</emphasis> (=2), and <emphasis role="strong">sticky bit</emphasis> (=1)
1094 </entry>
1095 </row>
1096 <row>
1097 <entry>
1098 2nd digit
1099 </entry>
1100 <entry>
1101 sum of <emphasis role="strong">read</emphasis> (=4), <emphasis role="strong">write</emphasis> (=2), and <emphasis role="strong">execute</emphasis> (=1) permissions for <emphasis role="strong">user</emphasis>
1102 </entry>
1103 </row>
1104 <row>
1105 <entry>
1106 3rd digit
1107 </entry>
1108 <entry>
1109 ditto for <emphasis role="strong">group</emphasis>
1110 </entry>
1111 </row>
1112 <row>
1113 <entry>
1114 4th digit
1115 </entry>
1116 <entry>
1117 ditto for <emphasis role="strong">other</emphasis>
1118 </entry>
1119 </row>
1120 </tbody>
1121 </tgroup>
1122 </table>
1123 <para>This sounds complicated but it is actually quite simple. If you look at the first few (2-10) columns from "<literal>ls -l</literal>" command output and read it as a binary (radix=2) representation of file permissions ("-" being "0" and "rwx" being "1"), the last 3 digit of the numeric mode value should make sense as an octal (radix=8) representation of file permissions to you.</para>
1124 <para>For example, try the following</para>
1125 <screen>$ touch foo bar
1126 $ chmod u=rw,go=r foo
1127 $ chmod 644 bar
1128 $ ls -l foo bar
1129 -rw-r--r-- 1 penguin penguin 17 2007-04-29 08:22 bar
1130 -rw-r--r-- 1 penguin penguin 12 2007-04-29 08:22 foo</screen>
1131 <tip>
1132 <para>If you need to access information displayed by "<literal>ls -l</literal>" in shell script, you should use pertinent commands such as <citerefentry><refentrytitle>test</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>stat</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>readlink</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The shell builtin such as "<literal>[</literal>" or "<literal>test</literal>" may be used too.</para>
1133 </tip>
1134 </section>
1135 <section id="_control_of_permissions_for_newly_created_files_umask">
1136 <title>Control of permissions for newly created files: umask</title>
1137 <para>What permissions are applied to a newly created file or directory is restricted by the <literal>umask</literal> shell builtin command. See <citerefentry><refentrytitle>dash</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry>, and <citerefentry><refentrytitle>builtins</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
1138 <screen> (file permissions) = (requested file permissions) &amp; ~(umask value)</screen>
1139 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1140 <title>The <emphasis role="strong">umask</emphasis> value examples</title>
1141 <tgroup cols="4">
1142 <colspec colwidth="38pt" align="left"/>
1143 <colspec colwidth="135pt" align="left"/>
1144 <colspec colwidth="162pt" align="left"/>
1145 <colspec colwidth="141pt" align="left"/>
1146 <thead>
1147 <row>
1148 <entry>
1149 umask
1150 </entry>
1151 <entry>
1152 file permissions created
1153 </entry>
1154 <entry>
1155 directory permissions created
1156 </entry>
1157 <entry>
1158 usage
1159 </entry>
1160 </row>
1161 </thead>
1162 <tbody>
1163 <row>
1164 <entry>
1165 <literal>0022</literal>
1166 </entry>
1167 <entry>
1168 <literal>-rw-r--r--</literal>
1169 </entry>
1170 <entry>
1171 <literal>-rwxr-xr-x</literal>
1172 </entry>
1173 <entry>
1174 writable only by the user
1175 </entry>
1176 </row>
1177 <row>
1178 <entry>
1179 <literal>0002</literal>
1180 </entry>
1181 <entry>
1182 <literal>-rw-rw-r--</literal>
1183 </entry>
1184 <entry>
1185 <literal>-rwxrwxr-x</literal>
1186 </entry>
1187 <entry>
1188 writable by the group
1189 </entry>
1190 </row>
1191 </tbody>
1192 </tgroup>
1193 </table>
1194 <para>The Debian system uses a user private group (UPG) scheme as its default. A UPG is created whenever a new user is added to the system. A UPG has the same name as the user for which it was created and that user is the only member of the UPG. UPG scheme makes it is safe to set umask to <literal>0002</literal> since every user has their own private group. (In some Unix variants, it is quite common to setup all normal users belonging to a single <emphasis role="strong"><literal>users</literal></emphasis> group and is good idea to set umask to <literal>0022</literal> for security in such cases.)</para>
1195 </section>
1196 <section id="_permissions_for_groups_of_users_group">
1197 <title>Permissions for groups of users (group)</title>
1198 <para>In order to make group permissions to be applied to a particular user, that user needs to be made a member of the group using "<literal>sudo vigr</literal>".</para>
1199 <note>
1200 <para>Alternatively, you may dynamically add users to groups during the authentication process by adding "<literal>auth optional pam_group.so</literal>" line to "<literal>/etc/pam.d/common-auth</literal>" and setting "<literal>/etc/security/group.conf</literal>". (See <xref linkend="_authentication"/>.)</para>
1201 </note>
1202 <para>The hardware devices are just another kind of file on the Debian system. If you have problems accessing devices such as CD-ROM and USB memory stick from a user account, you should make that user a member of the relevant group.</para>
1203 <para>Some notable system-provided groups allow their members to access particular files and devices without <literal>root</literal> privilege.</para>
1204 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1205 <title>List of notable system-provided groups for file access</title>
1206 <tgroup cols="2">
1207 <colspec colwidth="54pt" align="left"/>
1208 <colspec colwidth="423pt" align="left"/>
1209 <thead>
1210 <row>
1211 <entry>
1212 group
1213 </entry>
1214 <entry>
1215 description for accessible files and devices
1216 </entry>
1217 </row>
1218 </thead>
1219 <tbody>
1220 <row>
1221 <entry>
1222 <literal>dialout</literal>
1223 </entry>
1224 <entry>
1225 full and direct access to serial ports ("<literal>/dev/ttyS[0-3]</literal>")
1226 </entry>
1227 </row>
1228 <row>
1229 <entry>
1230 <literal>dip</literal>
1231 </entry>
1232 <entry>
1233 limited access to serial ports for <emphasis role="strong">Dialup IP</emphasis> connection to trusted peers
1234 </entry>
1235 </row>
1236 <row>
1237 <entry>
1238 <literal>cdrom</literal>
1239 </entry>
1240 <entry>
1241 CD-ROM, DVD+/-RW drives
1242 </entry>
1243 </row>
1244 <row>
1245 <entry>
1246 <literal>audio</literal>
1247 </entry>
1248 <entry>
1249 audio device
1250 </entry>
1251 </row>
1252 <row>
1253 <entry>
1254 <literal>video</literal>
1255 </entry>
1256 <entry>
1257 video device
1258 </entry>
1259 </row>
1260 <row>
1261 <entry>
1262 <literal>scanner</literal>
1263 </entry>
1264 <entry>
1265 scanner(s)
1266 </entry>
1267 </row>
1268 <row>
1269 <entry>
1270 <literal>adm</literal>
1271 </entry>
1272 <entry>
1273 system monitoring logs
1274 </entry>
1275 </row>
1276 <row>
1277 <entry>
1278 <literal>staff</literal>
1279 </entry>
1280 <entry>
1281 some directories for junior administrative work: "<literal>/usr/local</literal>", "<literal>/home</literal>"
1282 </entry>
1283 </row>
1284 </tbody>
1285 </tgroup>
1286 </table>
1287 <tip>
1288 <para>You need to belong to the <literal>dialout</literal> group to reconfigure modem, dial anywhere, etc. But if <literal>root</literal> creates pre-defined configuration files for trusted peers in "<literal>/etc/ppp/peers/</literal>", you only need to belong to the <literal>dip</literal> group to create <emphasis role="strong">Dialup IP</emphasis> connection to those trusted peers using <citerefentry><refentrytitle>pppd</refentrytitle><manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>pon</refentrytitle><manvolnum>1</manvolnum></citerefentry>, and <citerefentry><refentrytitle>poff</refentrytitle><manvolnum>1</manvolnum></citerefentry> commands.</para>
1289 </tip>
1290 <para>Some notable system-provided groups allow their members to execute particular commands without <literal>root</literal> privilege.</para>
1291 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1292 <title>List of notable system provided groups for particular command executions</title>
1293 <tgroup cols="2">
1294 <colspec colwidth="54pt" align="left"/>
1295 <colspec colwidth="418pt" align="left"/>
1296 <thead>
1297 <row>
1298 <entry>
1299 group
1300 </entry>
1301 <entry>
1302 accessible commands
1303 </entry>
1304 </row>
1305 </thead>
1306 <tbody>
1307 <row>
1308 <entry>
1309 <literal>sudo</literal>
1310 </entry>
1311 <entry>
1312 execute <literal>sudo</literal> without their password
1313 </entry>
1314 </row>
1315 <row>
1316 <entry>
1317 <literal>lpadmin</literal>
1318 </entry>
1319 <entry>
1320 execute commands to add, modify, and remove printers from printer databases
1321 </entry>
1322 </row>
1323 </tbody>
1324 </tgroup>
1325 </table>
1326 <para>For the full listing of the system provided users and groups, see the recent version of the "Users and Groups" document in "<literal>/usr/share/doc/base-passwd/users-and-groups.html</literal>" provided by the <literal>base-passwd</literal> package.</para>
1327 <para>See <citerefentry><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>group</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>shadow</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>newgrp</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>vipw</refentrytitle><manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>vigr</refentrytitle><manvolnum>8</manvolnum></citerefentry>, and <citerefentry><refentrytitle>pam_group</refentrytitle><manvolnum>8</manvolnum></citerefentry> for management commands of the user and group system.</para>
1328 </section>
1329 <section id="_timestamps">
1330 <title>Timestamps</title>
1331 <para>There are three types of timestamps for a GNU/Linux file.</para>
1332 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1333 <title>List of types of timestamps</title>
1334 <tgroup cols="2">
1335 <colspec colwidth="54pt" align="left"/>
1336 <colspec colwidth="211pt" align="left"/>
1337 <thead>
1338 <row>
1339 <entry>
1340 type
1341 </entry>
1342 <entry>
1343 meaning
1344 </entry>
1345 </row>
1346 </thead>
1347 <tbody>
1348 <row>
1349 <entry>
1350 <emphasis role="strong">mtime</emphasis>
1351 </entry>
1352 <entry>
1353 the file modification time (<literal>ls -l</literal>)
1354 </entry>
1355 </row>
1356 <row>
1357 <entry>
1358 <emphasis role="strong">ctime</emphasis>
1359 </entry>
1360 <entry>
1361 the file status change time (<literal>ls -lc</literal>)
1362 </entry>
1363 </row>
1364 <row>
1365 <entry>
1366 <emphasis role="strong">atime</emphasis>
1367 </entry>
1368 <entry>
1369 the last file access time (<literal>ls -lu</literal>)
1370 </entry>
1371 </row>
1372 </tbody>
1373 </tgroup>
1374 </table>
1375 <note>
1376 <para><emphasis role="strong">ctime</emphasis> is not file creation time.</para>
1377 </note>
1378 <itemizedlist>
1379 <listitem>
1380 <para>
1381 Overwriting a file changes all of the <emphasis role="strong">mtime</emphasis>, <emphasis role="strong">ctime</emphasis>, and <emphasis role="strong">atime</emphasis> attributes of the file.
1382 </para>
1383 </listitem>
1384 <listitem>
1385 <para>
1386 Changing ownership or permission of a file changes the <emphasis role="strong">ctime</emphasis> and <emphasis role="strong">atime</emphasis> attributes of the file.
1387 </para>
1388 </listitem>
1389 <listitem>
1390 <para>
1391 Reading a file changes the <emphasis role="strong">atime</emphasis> of the file.
1392 </para>
1393 </listitem>
1394 </itemizedlist>
1395 <note>
1396 <para>Even simply reading a file on the Debian system normally causes a file write operation to update <emphasis role="strong">atime</emphasis> information in the <emphasis role="strong">inode</emphasis>. Mounting a filesystem with "<literal>noatime</literal>" or "<literal>relatime</literal>" option makes the system skip this operation and results in faster file access for the read. This is often recommended for laptops, because it reduces hard drive activity and saves power. See <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
1397 </note>
1398 <para>Use <citerefentry><refentrytitle>touch</refentrytitle><manvolnum>1</manvolnum></citerefentry> command to change timestamps of existing files.</para>
1399 <para>For timestamps, the <literal>ls</literal> command outputs different strings under the modern English locale ("<literal>en_US.UTF-8</literal>") from under the old one ("<literal>C</literal>").</para>
1400 <screen>$ LANG=en_US.UTF-8 ls -l foo
1401 -rw-r--r-- 1 penguin penguin 3 2008-03-05 00:47 foo
1402 $ LANG=C ls -l foo
1403 -rw-r--r-- 1 penguin penguin 3 Mar 5 00:47 foo</screen>
1404 <tip>
1405 <para>See <xref linkend="_customized_display_of_time_and_date"/> to customize "<literal>ls -l</literal>" output.</para>
1406 </tip>
1407 </section>
1408 <section id="_links">
1409 <title>Links</title>
1410 <para>There are two methods of associating a file "<literal>foo</literal>" with a different filename "<literal>bar</literal>".</para>
1411 <itemizedlist>
1412 <listitem>
1413 <para>
1414 <ulink url="http://en.wikipedia.org/wiki/Hard_link">Hard link</ulink>
1415 </para>
1416 <itemizedlist>
1417 <listitem>
1418 <para>
1419 Duplicate name for an existing file
1420 </para>
1421 </listitem>
1422 <listitem>
1423 <para>
1424 "<literal>ln foo bar</literal>"
1425 </para>
1426 </listitem>
1427 </itemizedlist>
1428 </listitem>
1429 <listitem>
1430 <para>
1431 <ulink url="http://en.wikipedia.org/wiki/Symbolic_link">Symbolic link or symlink</ulink>
1432 </para>
1433 <itemizedlist>
1434 <listitem>
1435 <para>
1436 Special file that points to another file by name
1437 </para>
1438 </listitem>
1439 <listitem>
1440 <para>
1441 "<literal>ln -s foo bar</literal>"
1442 </para>
1443 </listitem>
1444 </itemizedlist>
1445 </listitem>
1446 </itemizedlist>
1447 <para>See the following example for changes in link counts and the subtle differences in the result of the <literal>rm</literal> command.</para>
1448 <screen>$ echo "Original Content" &gt; foo
1449 $ ls -li foo
1450 2398521 -rw-r--r-- 1 penguin penguin 17 2007-04-29 08:15 foo
1451 $ ln foo bar # hard link
1452 $ ln -s foo baz # symlink
1453 $ ls -li foo bar baz
1454 2398521 -rw-r--r-- 2 penguin penguin 17 2007-04-29 08:15 bar
1455 2398538 lrwxrwxrwx 1 penguin penguin 3 2007-04-29 08:16 baz -&gt; foo
1456 2398521 -rw-r--r-- 2 penguin penguin 17 2007-04-29 08:15 foo
1457 $ rm foo
1458 $ echo "New Content" &gt; foo
1459 $ ls -li foo bar baz
1460 2398521 -rw-r--r-- 1 penguin penguin 17 2007-04-29 08:15 bar
1461 2398538 lrwxrwxrwx 1 penguin penguin 3 2007-04-29 08:16 baz -&gt; foo
1462 2398540 -rw-r--r-- 1 penguin penguin 12 2007-04-29 08:17 foo
1463 $ cat bar
1464 Original Content
1465 $ cat baz
1466 New Content</screen>
1467 <para>The hardlink can be made within the same filesystem and shares the same inode number which the "<literal>-i</literal>" option with <citerefentry><refentrytitle>ls</refentrytitle><manvolnum>1</manvolnum></citerefentry> reveals.</para>
1468 <para>The symlink always has nominal file access permissions of "<literal>rwxrwxrwx</literal>", as shown in the above example, with the effective access permissions dictated by permissions of the file that it points to.</para>
1469 <caution>
1470 <para>It is generally good idea not to create complicated symbolic links or hardlinks at all unless you have a very good reason. It may cause nightmares where the logical combination of the symbolic links results in loops in the filesystem.</para>
1471 </caution>
1472 <note>
1473 <para>It is generally preferable to use symbolic links rather than hardlinks unless you have a good reason for using a hardlink.</para>
1474 </note>
1475 <para>The "<literal>.</literal>" directory links to the directory that it appears in, thus the link count of any new directory starts at 2. The "<literal>..</literal>" directory links to the parent directory, thus the link count of the directory increases with the addition of new subdirectories.</para>
1476 <para>If you are just moving to Linux from Windows, it soon becomes clear how well-designed the filename linking of Unix is, compared with the nearest Windows equivalent of "shortcuts". Because it is implemented in the filesystem, applications can't see any difference between a linked file and the original. In the case of hardlinks, there really is no difference.</para>
1477 </section>
1478 <section id="_named_pipes_fifos">
1479 <title>Named pipes (FIFOs)</title>
1480 <para>A <ulink url="http://en.wikipedia.org/wiki/Named_pipe">named pipe</ulink> is a file that acts like a pipe. You put something into the file, and it comes out the other end. Thus it's called a FIFO, or First-In-First-Out: the first thing you put in the pipe is the first thing to come out the other end.</para>
1481 <para>If you write to a named pipe, the process which is writing to the pipe doesn't terminate until the information being written is read from the pipe. If you read from a named pipe, the reading process waits until there is nothing to read before terminating. The size of the pipe is always zero --- it does not store data, it just links two processes like the shell "<literal>|</literal>". However, since this pipe has a name, the two processes don't have to be on the same command line or even be run by the same user. Pipes were a very influential innovation of Unix.</para>
1482 <para>For example, try the following</para>
1483 <screen>$ cd; mkfifo mypipe
1484 $ echo "hello" &gt;mypipe &amp; # put into background
1485 [1] 8022
1486 $ ls -l mypipe
1487 prw-r--r-- 1 penguin penguin 0 2007-04-29 08:25 mypipe
1488 $ cat mypipe
1489 hello
1490 [1]+ Done echo "hello" &gt;mypipe
1491 $ ls mypipe
1492 mypipe
1493 $ rm mypipe</screen>
1494 </section>
1495 <section id="_sockets">
1496 <title>Sockets</title>
1497 <para>Sockets are used extensively by all the Internet communication, databases, and the operating system itself. It is similar to the named pipe (FIFO) and allows processes to exchange information even between different computers. For the socket, those processes do not need to be running at the same time nor to be running as the children of the same ancestor process. This is the endpoint for <ulink url="http://en.wikipedia.org/wiki/Inter-process_communication">the inter process communication (IPC)</ulink>. The exchange of information may occur over the network between different hosts. The two most common ones are <ulink url="http://en.wikipedia.org/wiki/Internet_socket">the Internet socket</ulink> and <ulink url="http://en.wikipedia.org/wiki/Unix_domain_socket">the Unix domain socket</ulink>.</para>
1498 <tip>
1499 <para>"<literal>netstat -an</literal>" provides a very useful overview of sockets that are open on a given system.</para>
1500 </tip>
1501 </section>
1502 <section id="_device_files">
1503 <title>Device files</title>
1504 <para><ulink url="http://en.wikipedia.org/wiki/Device_file">Device files</ulink> refer to physical or virtual devices on your system, such as your hard disk, video card, screen, or keyboard. An example of a virtual device is the console, represented by "<literal>/dev/console</literal>".</para>
1505 <para>There are 2 types of device files.</para>
1506 <itemizedlist>
1507 <listitem>
1508 <para>
1509 <emphasis role="strong">Character device</emphasis>
1510 </para>
1511 <itemizedlist>
1512 <listitem>
1513 <para>
1514 Accessed one character at a time
1515 </para>
1516 </listitem>
1517 <listitem>
1518 <para>
1519 1 character = 1 byte
1520 </para>
1521 </listitem>
1522 <listitem>
1523 <para>
1524 E.g. keyboard device, serial port, …
1525 </para>
1526 </listitem>
1527 </itemizedlist>
1528 </listitem>
1529 <listitem>
1530 <para>
1531 <emphasis role="strong">Block device</emphasis>
1532 </para>
1533 <itemizedlist>
1534 <listitem>
1535 <para>
1536 accessed in larger units called blocks
1537 </para>
1538 </listitem>
1539 <listitem>
1540 <para>
1541 1 block &gt; 1 byte
1542 </para>
1543 </listitem>
1544 <listitem>
1545 <para>
1546 E.g. hard disk, …
1547 </para>
1548 </listitem>
1549 </itemizedlist>
1550 </listitem>
1551 </itemizedlist>
1552 <para>You can read and write device files, though the file may well contain binary data which may be an incomprehensible-to-humans gibberish. Writing data directly to these files is sometimes useful for the troubleshooting of hardware connections. For example, you can dump a text file to the printer device "<literal>/dev/lp0</literal>" or send modem commands to the appropriate serial port "<literal>/dev/ttyS0</literal>". But, unless this is done carefully, it may cause a major disaster. So be cautious.</para>
1553 <note>
1554 <para>For the normal access to a printer, use <citerefentry><refentrytitle>lp</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
1555 </note>
1556 <para>The device node number are displayed by executing <citerefentry><refentrytitle>ls</refentrytitle><manvolnum>1</manvolnum></citerefentry> as the following.</para>
1557 <screen>$ ls -l /dev/hda /dev/ttyS0 /dev/zero
1558 brw-rw---- 1 root cdrom 3, 0 2007-04-29 07:00 /dev/hda
1559 crw-rw---- 1 root dialout 4, 64 2007-04-29 07:00 /dev/ttyS0
1560 crw-rw-rw- 1 root root 1, 5 2007-04-29 07:00 /dev/zero</screen>
1561 <itemizedlist>
1562 <listitem>
1563 <para>
1564 "<literal>/dev/hda</literal>" has the major device number 3 and the minor device number 0. This is read/write accessible by the user who belongs to <literal>cdrom</literal> group.
1565 </para>
1566 </listitem>
1567 <listitem>
1568 <para>
1569 "<literal>/dev/ttyS0</literal>" has the major device number 4 and the minor device number 64. This is read/write accessible by the user who belongs to <literal>dialout</literal> group.
1570 </para>
1571 </listitem>
1572 <listitem>
1573 <para>
1574 "<literal>/dev/zero</literal>" has the major device number 1 and the minor device number 5. This is read/write accessible by anyone.
1575 </para>
1576 </listitem>
1577 </itemizedlist>
1578 <para>In the Linux 2.6 system, the filesystem under "<literal>/dev/</literal>" is automatically populated by the <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> mechanism.</para>
1579 </section>
1580 <section id="_special_device_files">
1581 <title>Special device files</title>
1582 <para>There are some special device files.</para>
1583 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1584 <title>List of special device files</title>
1585 <tgroup cols="3">
1586 <colspec colwidth="81pt" align="left"/>
1587 <colspec colwidth="38pt" align="left"/>
1588 <colspec colwidth="532pt" align="left"/>
1589 <thead>
1590 <row>
1591 <entry>
1592 device file
1593 </entry>
1594 <entry>
1595 action
1596 </entry>
1597 <entry>
1598 description of response
1599 </entry>
1600 </row>
1601 </thead>
1602 <tbody>
1603 <row>
1604 <entry>
1605 <literal>/dev/null</literal>
1606 </entry>
1607 <entry>
1608 read
1609 </entry>
1610 <entry>
1611 return "end-of-file (EOF) character"
1612 </entry>
1613 </row>
1614 <row>
1615 <entry>
1616 <literal>/dev/null</literal>
1617 </entry>
1618 <entry>
1619 write
1620 </entry>
1621 <entry>
1622 return nothing (a bottomless data dump pit)
1623 </entry>
1624 </row>
1625 <row>
1626 <entry>
1627 <literal>/dev/zero</literal>
1628 </entry>
1629 <entry>
1630 read
1631 </entry>
1632 <entry>
1633 return "the <literal>\0</literal> (NUL) character" (not the same as the number zero ASCII)
1634 </entry>
1635 </row>
1636 <row>
1637 <entry>
1638 <literal>/dev/random</literal>
1639 </entry>
1640 <entry>
1641 read
1642 </entry>
1643 <entry>
1644 return random characters from a true random number generator, delivering real entropy (slow)
1645 </entry>
1646 </row>
1647 <row>
1648 <entry>
1649 <literal>/dev/urandom</literal>
1650 </entry>
1651 <entry>
1652 read
1653 </entry>
1654 <entry>
1655 return random characters from a cryptographically secure pseudorandom number generator
1656 </entry>
1657 </row>
1658 <row>
1659 <entry>
1660 <literal>/dev/full</literal>
1661 </entry>
1662 <entry>
1663 write
1664 </entry>
1665 <entry>
1666 return the disk-full (ENOSPC) error
1667 </entry>
1668 </row>
1669 </tbody>
1670 </tgroup>
1671 </table>
1672 <para>These are frequently used in conjunction with the shell redirection (see <xref linkend="_typical_command_sequences_and_shell_redirection"/>).</para>
1673 </section>
1674 <section id="_procfs_and_sysfs">
1675 <title>procfs and sysfs</title>
1676 <para>The <ulink url="http://en.wikipedia.org/wiki/Procfs">procfs</ulink> and <ulink url="http://en.wikipedia.org/wiki/Sysfs">sysfs</ulink> mounted on "<literal>/proc</literal>" and "<literal>/sys</literal>" are the pseudo-filesystem and expose internal data structures of the kernel to the userspace. In other word, these entries are virtual, meaning that they act as a convenient window into the operation of the operating system.</para>
1677 <para>The directory "<literal>/proc</literal>" contains (among other things) one subdirectory for each process running on the system, which is named after the process ID (PID). System utilities that access process information, such as <citerefentry><refentrytitle>ps</refentrytitle><manvolnum>1</manvolnum></citerefentry>, get their information from this directory structure.</para>
1678 <para>The directories under "<literal>/proc/sys/</literal>" contain interface to change certain kernel parameters at run time. (You may do the same through specialized <citerefentry><refentrytitle>sysctl</refentrytitle><manvolnum>8</manvolnum></citerefentry> command or its preload/configuration file "<literal>/etc/sysctrl.conf</literal>".)</para>
1679 <note>
1680 <para>The Linux kernel may complain "Too many open files". You can fix this by increasing "<literal>file-max</literal>" value to a larger value from the root shell, e.g., "<literal>echo "65536" &gt; /proc/sys/fs/file-max</literal>" (This was needed on older kernels).</para>
1681 </note>
1682 <para>People frequently panic when they notice one file in particular - "<literal>/proc/kcore</literal>" - which is generally huge. This is (more or less) a copy of the content of your computer's memory. It's used to debug the kernel. It is a virtual file that points to computer memory, so don't worry about its size.</para>
1683 <para>The directory under "<literal>/sys</literal>" contains exported kernel data structures, their attributes, and their linkages between them. It also contains interface to change certain kernel parameters at run time.</para>
1684 <para>See "<literal>proc.txt(.gz)</literal>", "<literal>sysfs.txt(.gz)</literal>" and other related documents in the Linux kernel documentation ("<literal>/usr/share/doc/linux-doc-2.6.*/Documentation/filesystems/*</literal>") provided by the <literal>linux-doc-2.6.*</literal> package.</para>
1685 </section>
1686 <section id="_tmpfs">
1687 <title>tmpfs</title>
1688 <para>The <ulink url="http://en.wikipedia.org/wiki/Tmpfs#Linux">tmpfs</ulink> is a temporary filesystem which keeps all files in the <ulink url="http://en.wikipedia.org/wiki/Virtual_memory">virtual memory</ulink>. The data of the tmpfs in the <ulink url="http://en.wikipedia.org/wiki/Page_cache">page cache</ulink> on memory may be swapped out to the <ulink url="http://en.wikipedia.org/wiki/Paging">swap space</ulink> on disk as needed.</para>
1689 <para>The directory "<literal>/run</literal>" is mounted as the tmpfs in the early boot process. This enables writing to it even when the directory "<literal>/</literal>" is mounted as read-only. This is the new location for the storage of transient state files and replaces several locations described in the <ulink url="http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard">Filesystem Hierarchy Standard</ulink> version 2.3:</para>
1690 <itemizedlist>
1691 <listitem>
1692 <para>
1693 "<literal>/var/run</literal>" → "<literal>/run</literal>"
1694 </para>
1695 </listitem>
1696 <listitem>
1697 <para>
1698 "<literal>/var/lock</literal>" → "<literal>/run/lock</literal>"
1699 </para>
1700 </listitem>
1701 <listitem>
1702 <para>
1703 "<literal>/dev/shm</literal>" → "<literal>/run/shm</literal>"
1704 </para>
1705 </listitem>
1706 </itemizedlist>
1707 <para>See "<literal>tmpfs.txt(.gz)</literal>" in the Linux kernel documentation ("<literal>/usr/share/doc/linux-doc-*/Documentation/filesystems/*</literal>") provided by the <literal>linux-doc-*</literal> package.</para>
1708 </section>
1709 </section>
1710 <section id="_midnight_commander_mc">
1711 <title>Midnight Commander (MC)</title>
1712 <para><ulink url="http://en.wikipedia.org/wiki/Midnight_Commander">Midnight Commander (MC)</ulink> is a GNU "Swiss army knife" for the Linux console and other terminal environments. This gives newbie a menu driven console experience which is much easier to learn than standard Unix commands.</para>
1713 <para>You may need to install the Midnight Commander package which is titled "<literal>mc</literal>" by the following.</para>
1714 <screen>$ sudo apt-get install mc</screen>
1715 <para>Use the <citerefentry><refentrytitle>mc</refentrytitle><manvolnum>1</manvolnum></citerefentry> command to explore the Debian system. This is the best way to learn. Please explore few interesting locations just using the cursor keys and Enter key.</para>
1716 <itemizedlist>
1717 <listitem>
1718 <para>
1719 "<literal>/etc</literal>" and its subdirectories
1720 </para>
1721 </listitem>
1722 <listitem>
1723 <para>
1724 "<literal>/var/log</literal>" and its subdirectories
1725 </para>
1726 </listitem>
1727 <listitem>
1728 <para>
1729 "<literal>/usr/share/doc</literal>" and its subdirectories
1730 </para>
1731 </listitem>
1732 <listitem>
1733 <para>
1734 "<literal>/sbin</literal>" and "<literal>/bin</literal>"
1735 </para>
1736 </listitem>
1737 </itemizedlist>
1738 <section id="_customization_of_mc">
1739 <title>Customization of MC</title>
1740 <para>In order to make MC to change working directory upon exit and <literal>cd</literal> to the directory, I suggest to modify "<literal>~/.bashrc</literal>" to include a script provided by the <literal>mc</literal> package.</para>
1741 <screen>. /usr/lib/mc/mc.sh</screen>
1742 <para>See <citerefentry><refentrytitle>mc</refentrytitle><manvolnum>1</manvolnum></citerefentry> (under the "<literal>-P</literal>" option) for the reason. (If you do not understand what exactly I am talking here, you can do this later.)</para>
1743 </section>
1744 <section id="_starting_mc">
1745 <title>Starting MC</title>
1746 <para>MC can be started by the following.</para>
1747 <screen>$ mc</screen>
1748 <para>MC takes care of all file operations through its menu, requiring minimal user effort. Just press F1 to get the help screen. You can play with MC just by pressing cursor-keys and function-keys.</para>
1749 <note>
1750 <para>In some consoles such as <citerefentry><refentrytitle>gnome-terminal</refentrytitle><manvolnum>1</manvolnum></citerefentry>, key strokes of function-keys may be stolen by the console program. You can disable these features by "Edit" → "Keyboard Shortcuts" for <literal>gnome-terminal</literal>.</para>
1751 </note>
1752 <para>If you encounter character encoding problem which displays garbage characters, adding "<literal>-a</literal>" to MC's command line may help prevent problems.</para>
1753 <para>If this doesn't clear up your display problems with MC, see <xref linkend="_the_terminal_configuration"/>.</para>
1754 </section>
1755 <section id="_file_manager_in_mc">
1756 <title>File manager in MC</title>
1757 <para>The default is two directory panels containing file lists. Another useful mode is to set the right window to "information" to see file access privilege information, etc. Following are some essential keystrokes. With the <citerefentry><refentrytitle>gpm</refentrytitle><manvolnum>8</manvolnum></citerefentry> daemon running, one can use a mouse on Linux character consoles, too. (Make sure to press the shift-key to obtain the normal behavior of cut and paste in MC.)</para>
1758 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1759 <title>The key bindings of MC</title>
1760 <tgroup cols="2">
1761 <colspec colwidth="114pt" align="left"/>
1762 <colspec colwidth="293pt" align="left"/>
1763 <thead>
1764 <row>
1765 <entry>
1766 key
1767 </entry>
1768 <entry>
1769 key binding
1770 </entry>
1771 </row>
1772 </thead>
1773 <tbody>
1774 <row>
1775 <entry>
1776 <literal>F1</literal>
1777 </entry>
1778 <entry>
1779 help menu
1780 </entry>
1781 </row>
1782 <row>
1783 <entry>
1784 <literal>F3</literal>
1785 </entry>
1786 <entry>
1787 internal file viewer
1788 </entry>
1789 </row>
1790 <row>
1791 <entry>
1792 <literal>F4</literal>
1793 </entry>
1794 <entry>
1795 internal editor
1796 </entry>
1797 </row>
1798 <row>
1799 <entry>
1800 <literal>F9</literal>
1801 </entry>
1802 <entry>
1803 activate pull down menu
1804 </entry>
1805 </row>
1806 <row>
1807 <entry>
1808 <literal>F10</literal>
1809 </entry>
1810 <entry>
1811 exit Midnight Commander
1812 </entry>
1813 </row>
1814 <row>
1815 <entry>
1816 <literal>Tab</literal>
1817 </entry>
1818 <entry>
1819 move between two windows
1820 </entry>
1821 </row>
1822 <row>
1823 <entry><literal>Insert</literal> or <literal>Ctrl-T</literal>
1824 </entry>
1825 <entry>
1826 mark file for a multiple-file operation such as copy
1827 </entry>
1828 </row>
1829 <row>
1830 <entry>
1831 <literal>Del</literal>
1832 </entry>
1833 <entry>
1834 delete file (be careful---set MC to safe delete mode)
1835 </entry>
1836 </row>
1837 <row>
1838 <entry>
1839 Cursor keys
1840 </entry>
1841 <entry>
1842 self-explanatory
1843 </entry>
1844 </row>
1845 </tbody>
1846 </tgroup>
1847 </table>
1848 </section>
1849 <section id="_command_line_tricks_in_mc">
1850 <title>Command-line tricks in MC</title>
1851 <itemizedlist>
1852 <listitem>
1853 <para><literal>cd</literal> command changes the directory shown on the selected screen.
1854 </para>
1855 </listitem>
1856 <listitem>
1857 <para><literal>Ctrl-Enter</literal> or <literal>Alt-Enter</literal> copies a filename to the command line. Use this with <citerefentry><refentrytitle>cp</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>mv</refentrytitle><manvolnum>1</manvolnum></citerefentry> commands together with command-line editing.
1858 </para>
1859 </listitem>
1860 <listitem>
1861 <para><literal>Alt-Tab</literal> shows shell filename expansion choices.
1862 </para>
1863 </listitem>
1864 <listitem>
1865 <para>
1866 One can specify the starting directory for both windows as arguments to MC; for example, "<literal>mc /etc /root</literal>".
1867 </para>
1868 </listitem>
1869 <listitem>
1870 <para><literal>Esc</literal> + <literal>n-key</literal> → <literal>Fn</literal> (i.e., <literal>Esc</literal> + <literal>1</literal> → <literal>F1</literal>, etc.; <literal>Esc</literal> + <literal>0</literal> → <literal>F10</literal>)
1871 </para>
1872 </listitem>
1873 <listitem>
1874 <para>
1875 Pressing <literal>Esc</literal> before the key has the same effect as pressing the <literal>Alt</literal> and the key together.; i.e., type <literal>Esc</literal> + <literal>c</literal> for <literal>Alt-C</literal>. <literal>Esc</literal> is called meta-key and sometimes noted as "<literal>M-</literal>".
1876 </para>
1877 </listitem>
1878 </itemizedlist>
1879 </section>
1880 <section id="_the_internal_editor_in_mc">
1881 <title>The internal editor in MC</title>
1882 <para>The internal editor has an interesting cut-and-paste scheme. Pressing <literal>F3</literal> marks the start of a selection, a second <literal>F3</literal> marks the end of selection and highlights the selection. Then you can move your cursor. If you press F6, the selected area is moved to the cursor location. If you press F5, the selected area is copied and inserted at the cursor location. <literal>F2</literal> saves the file. <literal>F10</literal> gets you out. Most cursor keys work intuitively.</para>
1883 <para>This editor can be directly started on a file using one of the following commands.</para>
1884 <screen>$ mc -e filename_to_edit</screen>
1885 <screen>$ mcedit filename_to_edit</screen>
1886 <para>This is not a multi-window editor, but one can use multiple Linux consoles to achieve the same effect. To copy between windows, use Alt-F&lt;n&gt; keys to switch virtual consoles and use "File→Insert file" or "File→Copy to file" to move a portion of a file to another file.</para>
1887 <para>This internal editor can be replaced with any external editor of choice.</para>
1888 <para>Also, many programs use the environment variables "<literal>$EDITOR</literal>" or "<literal>$VISUAL</literal>" to decide which editor to use. If you are uncomfortable with <citerefentry><refentrytitle>vim</refentrytitle><manvolnum>1</manvolnum></citerefentry> or <citerefentry><refentrytitle>nano</refentrytitle><manvolnum>1</manvolnum></citerefentry> initially, you may set these to "<literal>mcedit</literal>" by adding the following lines to "<literal>~/.bashrc</literal>".</para>
1889 <screen>export EDITOR=mcedit
1890 export VISUAL=mcedit</screen>
1891 <para>I do recommend setting these to "<literal>vim</literal>" if possible.</para>
1892 <para>If you are uncomfortable with <citerefentry><refentrytitle>vim</refentrytitle><manvolnum>1</manvolnum></citerefentry>, you can keep using <citerefentry><refentrytitle>mcedit</refentrytitle><manvolnum>1</manvolnum></citerefentry> for most system maintenance tasks.</para>
1893 </section>
1894 <section id="_the_internal_viewer_in_mc">
1895 <title>The internal viewer in MC</title>
1896 <para>MC is a very smart viewer. This is a great tool for searching words in documents. I always use this for files in the "<literal>/usr/share/doc</literal>" directory. This is the fastest way to browse through masses of Linux information. This viewer can be directly started using one of the following commands.</para>
1897 <screen>$ mc -v path/to/filename_to_view</screen>
1898 <screen>$ mcview path/to/filename_to_view</screen>
1899 </section>
1900 <section id="_auto_start_features_of_mc">
1901 <title>Auto-start features of MC</title>
1902 <para>Press Enter on a file, and the appropriate program handles the content of the file (see <xref linkend="_customizing_program_to_be_started"/>). This is a very convenient MC feature.</para>
1903 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
1904 <title>The reaction to the enter key in MC</title>
1905 <tgroup cols="2">
1906 <colspec colwidth="184pt" align="left"/>
1907 <colspec colwidth="211pt" align="left"/>
1908 <thead>
1909 <row>
1910 <entry>
1911 file type
1912 </entry>
1913 <entry>
1914 reaction to enter key
1915 </entry>
1916 </row>
1917 </thead>
1918 <tbody>
1919 <row>
1920 <entry>
1921 executable file
1922 </entry>
1923 <entry>
1924 execute command
1925 </entry>
1926 </row>
1927 <row>
1928 <entry>
1929 man file
1930 </entry>
1931 <entry>
1932 pipe content to viewer software
1933 </entry>
1934 </row>
1935 <row>
1936 <entry>
1937 html file
1938 </entry>
1939 <entry>
1940 pipe content to web browser
1941 </entry>
1942 </row>
1943 <row>
1944 <entry>
1945 "<literal>*.tar.gz</literal>" and "<literal>*.deb</literal>" file
1946 </entry>
1947 <entry>
1948 browse its contents as if subdirectory
1949 </entry>
1950 </row>
1951 </tbody>
1952 </tgroup>
1953 </table>
1954 <para>In order to allow these viewer and virtual file features to function, viewable files should not be set as executable. Change their status using <citerefentry><refentrytitle>chmod</refentrytitle><manvolnum>1</manvolnum></citerefentry> or via the MC file menu.</para>
1955 </section>
1956 <section id="_ftp_virtual_filesystem_of_mc">
1957 <title>FTP virtual filesystem of MC</title>
1958 <para>MC can be used to access files over the Internet using FTP. Go to the menu by pressing <literal>F9</literal>, then type "<literal>p</literal>" to activate the FTP virtual filesystem. Enter a URL in the form "<literal>username:passwd@hostname.domainname</literal>", which retrieves a remote directory that appears like a local one.</para>
1959 <para>Try "[http.us.debian.org/debian]" as the URL and browse the Debian archive.</para>
1960 </section>
1961 </section>
1962 <section id="_the_basic_unix_like_work_environment">
1963 <title>The basic Unix-like work environment</title>
1964 <para>Although MC enables you to do almost everything, it is very important for you to learn how to use the command line tools invoked from the shell prompt and become familiar with the Unix-like work environment.</para>
1965 <section id="_the_login_shell">
1966 <title>The login shell</title>
1967 <para>You can select your login shell with <citerefentry><refentrytitle>chsh</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
1968 <table id="list-of-shell-programs" pgwide="0" frame="topbot" rowsep="1" colsep="1">
1969 <title>List of shell programs</title>
1970 <tgroup cols="5">
1971 <colspec colwidth="43pt" align="left"/>
1972 <colspec colwidth="76pt" align="left"/>
1973 <colspec colwidth="70pt" align="left"/>
1974 <colspec colwidth="65pt" align="left"/>
1975 <colspec colwidth="494pt" align="left"/>
1976 <thead>
1977 <row>
1978 <entry>
1979 package
1980 </entry>
1981 <entry>
1982 popcon
1983 </entry>
1984 <entry>
1985 size
1986 </entry>
1987 <entry>
1988 POSIX shell
1989 </entry>
1990 <entry>
1991 description
1992 </entry>
1993 </row>
1994 </thead>
1995 <tbody>
1996 <row>
1997 <entry>
1998 <literal>bash</literal>
1999 </entry>
2000 <entry>
2001 @-@popcon1@-@
2002 </entry>
2003 <entry>
2004 @-@psize1@-@
2005 </entry>
2006 <entry>
2007 Yes
2008 </entry>
2009 <entry><ulink url="http://en.wikipedia.org/wiki/Bash">Bash</ulink>: the GNU Bourne Again SHell (de facto standard)
2010 </entry>
2011 </row>
2012 <row>
2013 <entry>
2014 <literal>tcsh</literal>
2015 </entry>
2016 <entry>
2017 @-@popcon1@-@
2018 </entry>
2019 <entry>
2020 @-@psize1@-@
2021 </entry>
2022 <entry>
2023 No
2024 </entry>
2025 <entry><ulink url="http://en.wikipedia.org/wiki/Tcsh">TENEX C Shell</ulink>: an enhanced version of <ulink url="http://en.wikipedia.org/wiki/C_shell">Berkeley csh</ulink></entry>
2026 </row>
2027 <row>
2028 <entry>
2029 <literal>dash</literal>
2030 </entry>
2031 <entry>
2032 @-@popcon1@-@
2033 </entry>
2034 <entry>
2035 @-@psize1@-@
2036 </entry>
2037 <entry>
2038 Yes
2039 </entry>
2040 <entry>
2041 Debian <ulink url="http://en.wikipedia.org/wiki/Almquist_shell">Almquist Shell</ulink>, good for shell script
2042 </entry>
2043 </row>
2044 <row>
2045 <entry>
2046 <literal>zsh</literal>
2047 </entry>
2048 <entry>
2049 @-@popcon1@-@
2050 </entry>
2051 <entry>
2052 @-@psize1@-@
2053 </entry>
2054 <entry>
2055 Yes
2056 </entry>
2057 <entry><ulink url="http://en.wikipedia.org/wiki/Z_shell">Z shell</ulink>: the standard shell with many enhancements
2058 </entry>
2059 </row>
2060 <row>
2061 <entry>
2062 <literal>pdksh</literal>
2063 </entry>
2064 <entry>
2065 @-@popcon1@-@
2066 </entry>
2067 <entry>
2068 @-@psize1@-@
2069 </entry>
2070 <entry>
2071 Yes
2072 </entry>
2073 <entry>
2074 public domain version of the <ulink url="http://en.wikipedia.org/wiki/Korn_shell">Korn shell</ulink>
2075 </entry>
2076 </row>
2077 <row>
2078 <entry>
2079 <literal>csh</literal>
2080 </entry>
2081 <entry>
2082 @-@popcon1@-@
2083 </entry>
2084 <entry>
2085 @-@psize1@-@
2086 </entry>
2087 <entry>
2088 No
2089 </entry>
2090 <entry><ulink url="http://en.wikipedia.org/wiki/OpenBSD">OpenBSD</ulink> C Shell, a version of <ulink url="http://en.wikipedia.org/wiki/C_shell">Berkeley csh</ulink>
2091 </entry>
2092 </row>
2093 <row>
2094 <entry>
2095 <literal>sash</literal>
2096 </entry>
2097 <entry>
2098 @-@popcon1@-@
2099 </entry>
2100 <entry>
2101 @-@psize1@-@
2102 </entry>
2103 <entry>
2104 Yes
2105 </entry>
2106 <entry><ulink url="http://en.wikipedia.org/wiki/Stand-alone_shell">Stand-alone shell</ulink> with builtin commands (Not meant for standard "<literal>/bin/sh</literal>")
2107 </entry>
2108 </row>
2109 <row>
2110 <entry>
2111 <literal>ksh</literal>
2112 </entry>
2113 <entry>
2114 @-@popcon1@-@
2115 </entry>
2116 <entry>
2117 @-@psize1@-@
2118 </entry>
2119 <entry>
2120 Yes
2121 </entry>
2122 <entry>
2123 the real, AT&amp;T version of the <ulink url="http://en.wikipedia.org/wiki/Korn_shell">Korn shell</ulink>
2124 </entry>
2125 </row>
2126 <row>
2127 <entry>
2128 <literal>rc</literal>
2129 </entry>
2130 <entry>
2131 @-@popcon1@-@
2132 </entry>
2133 <entry>
2134 @-@psize1@-@
2135 </entry>
2136 <entry>
2137 No
2138 </entry>
2139 <entry>
2140 implementation of the <ulink url="http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs">AT&amp;T Plan 9</ulink> <ulink url="http://en.wikipedia.org/wiki/Rc">rc shell</ulink>
2141 </entry>
2142 </row>
2143 <row>
2144 <entry>
2145 <literal>posh</literal>
2146 </entry>
2147 <entry>
2148 @-@popcon1@-@
2149 </entry>
2150 <entry>
2151 @-@psize1@-@
2152 </entry>
2153 <entry>
2154 Yes
2155 </entry>
2156 <entry>
2157 Policy-compliant Ordinary SHell (<literal>pdksh</literal> derivative)
2158 </entry>
2159 </row>
2160 </tbody>
2161 </tgroup>
2162 </table>
2163 <para>In this tutorial chapter, the interactive shell always means <literal>bash</literal>.</para>
2164 </section>
2165 <section id="_customizing_bash">
2166 <title>Customizing bash</title>
2167 <para>You can customize <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry> behavior by "<literal>~/.bashrc</literal>".</para>
2168 <para>For example, try the following.</para>
2169 <screen># CD upon exiting MC
2170 . /usr/lib/mc/mc.sh
2171
2172 # set CDPATH to good one
2173 CDPATH=.:/usr/share/doc:~:~/Desktop:~
2174 export CDPATH
2175
2176 PATH="${PATH}":/usr/sbin:/sbin
2177 # set PATH so it includes user's private bin if it exists
2178 if [ -d ~/bin ] ; then
2179 PATH=~/bin:"${PATH}"
2180 fi
2181 export PATH
2182
2183 EDITOR=vim
2184 export EDITOR</screen>
2185 <tip>
2186 <para>You can find more <literal>bash</literal> customization tips, such as <xref linkend="_colorized_commands"/>, in <xref linkend="_system_tips"/>.</para>
2187 </tip>
2188 </section>
2189 <section id="_special_key_strokes">
2190 <title>Special key strokes</title>
2191 <para>In the <ulink url="http://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> environment, there are few key strokes which have special meanings. Please note that on a normal Linux character console, only the left-hand <literal>Ctrl</literal> and <literal>Alt</literal> keys work as expected. Here are few notable key strokes to remember.</para>
2192 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
2193 <title>List of key bindings for bash</title>
2194 <tgroup cols="2">
2195 <colspec colwidth="233pt" align="left"/>
2196 <colspec colwidth="352pt" align="left"/>
2197 <thead>
2198 <row>
2199 <entry>
2200 key
2201 </entry>
2202 <entry>
2203 description of key binding
2204 </entry>
2205 </row>
2206 </thead>
2207 <tbody>
2208 <row>
2209 <entry>
2210 <literal>Ctrl-U</literal>
2211 </entry>
2212 <entry>
2213 erase line before cursor
2214 </entry>
2215 </row>
2216 <row>
2217 <entry>
2218 <literal>Ctrl-H</literal>
2219 </entry>
2220 <entry>
2221 erase a character before cursor
2222 </entry>
2223 </row>
2224 <row>
2225 <entry>
2226 <literal>Ctrl-D</literal>
2227 </entry>
2228 <entry>
2229 terminate input (exit shell if you are using shell)
2230 </entry>
2231 </row>
2232 <row>
2233 <entry>
2234 <literal>Ctrl-C</literal>
2235 </entry>
2236 <entry>
2237 terminate a running program
2238 </entry>
2239 </row>
2240 <row>
2241 <entry>
2242 <literal>Ctrl-Z</literal>
2243 </entry>
2244 <entry>
2245 temporarily stop program by moving it to the background job
2246 </entry>
2247 </row>
2248 <row>
2249 <entry>
2250 <literal>Ctrl-S</literal>
2251 </entry>
2252 <entry>
2253 halt output to screen
2254 </entry>
2255 </row>
2256 <row>
2257 <entry>
2258 <literal>Ctrl-Q</literal>
2259 </entry>
2260 <entry>
2261 reactivate output to screen
2262 </entry>
2263 </row>
2264 <row>
2265 <entry>
2266 <literal>Ctrl-Alt-Del</literal>
2267 </entry>
2268 <entry>
2269 reboot/halt the system, see <citerefentry><refentrytitle>inittab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2270 </entry>
2271 </row>
2272 <row>
2273 <entry><literal>Left-Alt-key</literal> (optionally, <literal>Windows-key</literal>)
2274 </entry>
2275 <entry>
2276 meta-key for Emacs and the similar UI
2277 </entry>
2278 </row>
2279 <row>
2280 <entry>
2281 <literal>Up-arrow</literal>
2282 </entry>
2283 <entry>
2284 start command history search under <literal>bash</literal>
2285 </entry>
2286 </row>
2287 <row>
2288 <entry>
2289 <literal>Ctrl-R</literal>
2290 </entry>
2291 <entry>
2292 start incremental command history search under <literal>bash</literal>
2293 </entry>
2294 </row>
2295 <row>
2296 <entry>
2297 <literal>Tab</literal>
2298 </entry>
2299 <entry>
2300 complete input of the filename to the command line under <literal>bash</literal>
2301 </entry>
2302 </row>
2303 <row>
2304 <entry>
2305 <literal>Ctrl-V</literal>
2306 <literal>Tab</literal>
2307 </entry>
2308 <entry>
2309 input <literal>Tab</literal> without expansion to the command line under <literal>bash</literal>
2310 </entry>
2311 </row>
2312 </tbody>
2313 </tgroup>
2314 </table>
2315 <tip>
2316 <para>The terminal feature of <literal>Ctrl-S</literal> can be disabled using <citerefentry><refentrytitle>stty</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
2317 </tip>
2318 </section>
2319 <section id="_unix_style_mouse_operations">
2320 <title>Unix style mouse operations</title>
2321 <para>Unix style mouse operations are based on the 3 button mouse system.</para>
2322 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
2323 <title>List of Unix style mouse operations</title>
2324 <tgroup cols="2">
2325 <colspec colwidth="141pt" align="left"/>
2326 <colspec colwidth="298pt" align="left"/>
2327 <thead>
2328 <row>
2329 <entry>
2330 action
2331 </entry>
2332 <entry>
2333 response
2334 </entry>
2335 </row>
2336 </thead>
2337 <tbody>
2338 <row>
2339 <entry>
2340 Left-click-and-drag mouse
2341 </entry>
2342 <entry>
2343 select and copy to the clipboard
2344 </entry>
2345 </row>
2346 <row>
2347 <entry>
2348 Left-click
2349 </entry>
2350 <entry>
2351 select the start of selection
2352 </entry>
2353 </row>
2354 <row>
2355 <entry>
2356 Right-click
2357 </entry>
2358 <entry>
2359 select the end of selection and copy to the clipboard
2360 </entry>
2361 </row>
2362 <row>
2363 <entry>
2364 Middle-click
2365 </entry>
2366 <entry>
2367 paste clipboard at the cursor
2368 </entry>
2369 </row>
2370 </tbody>
2371 </tgroup>
2372 </table>
2373 <para>The center wheel on the modern wheel mouse is considered middle mouse button and can be used for middle-click. Clicking left and right mouse buttons together serves as the middle-click under the 2 button mouse system situation. In order to use a mouse in Linux character consoles, you need to have <citerefentry><refentrytitle>gpm</refentrytitle><manvolnum>8</manvolnum></citerefentry> running as daemon.</para>
2374 </section>
2375 <section id="_the_pager">
2376 <title>The pager</title>
2377 <para><citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry> is the enhanced pager (file content browser). Hit "<literal>h</literal>" for help. It can do much more than <citerefentry><refentrytitle>more</refentrytitle><manvolnum>1</manvolnum></citerefentry> and can be supercharged by executing "<literal>eval $(lesspipe)</literal>" or "<literal>eval $(lessfile)</literal>" in the shell startup script. See more in "<literal>/usr/share/doc/lessf/LESSOPEN</literal>". The "<literal>-R</literal>" option allows raw character output and enables ANSI color escape sequences. See <citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
2378 </section>
2379 <section id="_the_text_editor">
2380 <title>The text editor</title>
2381 <para>You should become proficient in one of variants of <ulink url="http://en.wikipedia.org/wiki/Vim_(text_editor)">Vim</ulink> or <ulink url="http://en.wikipedia.org/wiki/Emacs">Emacs</ulink> programs which are popular in the Unix-like system.</para>
2382 <para>I think getting used to Vim commands is the right thing to do, since Vi-editor is always there in the Linux/Unix world. (Actually, original <literal>vi</literal> or new <literal>nvi</literal> are programs you find everywhere. I chose Vim instead for newbie since it offers you help through <literal>F1</literal> key while it is similar enough and more powerful.)</para>
2383 <para>If you chose either <ulink url="http://en.wikipedia.org/wiki/Emacs">Emacs</ulink> or <ulink url="http://en.wikipedia.org/wiki/XEmacs">XEmacs</ulink> instead as your choice of the editor, that is another good choice indeed, particularly for programming. Emacs has a plethora of other features as well, including functioning as a newsreader, directory editor, mail program, etc. When used for programming or editing shell scripts, it intelligently recognizes the format of what you are working on, and tries to provide assistance. Some people maintain that the only program they need on Linux is Emacs. Ten minutes learning Emacs now can save hours later. Having the GNU Emacs manual for reference when learning Emacs is highly recommended.</para>
2384 <para>All these programs usually come with tutoring program for you to learn them by practice. Start Vim by typing "<literal>vim</literal>" and press F1-key. You should at least read the first 35 lines. Then do the online training course by moving cursor to "<literal>|tutor|</literal>" and pressing <literal>Ctrl-]</literal>.</para>
2385 <note>
2386 <para>Good editors, such as Vim and Emacs, can be used to handle UTF-8 and other exotic encoding texts correctly with proper option in the x-terminal-emulator on X under UTF-8 locale with proper font settings. Please refer to their documentation on multibyte text.</para>
2387 </note>
2388 </section>
2389 <section id="_setting_a_default_text_editor">
2390 <title>Setting a default text editor</title>
2391 <para>Debian comes with a number of different editors. We recommend to install the <literal>vim</literal> package, as mentioned above.</para>
2392 <para>Debian provides unified access to the system default editor via command "<literal>/usr/bin/editor</literal>" so other programs (e.g., <citerefentry><refentrytitle>reportbug</refentrytitle><manvolnum>1</manvolnum></citerefentry>) can invoke it. You can change it by the following.</para>
2393 <screen>$ sudo update-alternatives --config editor</screen>
2394 <para>The choice "<literal>/usr/bin/vim.basic</literal>" over "<literal>/usr/bin/vim.tiny</literal>" is my recommendation for newbies since it supports syntax highlighting.</para>
2395 <tip>
2396 <para>Many programs use the environment variables "<literal>$EDITOR</literal>" or "<literal>$VISUAL</literal>" to decide which editor to use (see <xref linkend="_the_internal_editor_in_mc"/> and <xref linkend="_customizing_program_to_be_started"/>). For the consistency on Debian system, set these to "<literal>/usr/bin/editor</literal>". (Historically, "<literal>$EDITOR</literal>" was "<literal>ed</literal>" and "<literal>$VISUAL</literal>" was "<literal>vi</literal>".)</para>
2397 </tip>
2398 </section>
2399 <section id="_customizing_vim">
2400 <title>Customizing vim</title>
2401 <para>You can customize <citerefentry><refentrytitle>vim</refentrytitle><manvolnum>1</manvolnum></citerefentry> behavior by "<literal>~/.vimrc</literal>".</para>
2402 <para>For example, try the following</para>
2403 <screen>" -------------------------------
2404 " Local configuration
2405 "
2406 set nocompatible
2407 set nopaste
2408 set pastetoggle=&lt;f2&gt;
2409 syn on
2410 if $USER == "root"
2411 set nomodeline
2412 set noswapfile
2413 else
2414 set modeline
2415 set swapfile
2416 endif
2417 " filler to avoid the line above being recognized as a modeline
2418 " filler
2419 " filler</screen>
2420 </section>
2421 <section id="_recording_the_shell_activities">
2422 <title>Recording the shell activities</title>
2423 <para>The output of the shell command may roll off your screen and may be lost forever. It is good practice to log shell activities into the file for you to review them later. This kind of record is essential when you perform any system administration tasks.</para>
2424 <para>The basic method of recording the shell activity is to run it under <citerefentry><refentrytitle>script</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
2425 <para>For example, try the following</para>
2426 <screen>$ script
2427 Script started, file is typescript</screen>
2428 <para>Do whatever shell commands under <literal>script</literal>.</para>
2429 <para>Press <literal>Ctrl-D</literal> to exit <literal>script</literal>.</para>
2430 <screen>$ vim typescript</screen>
2431 <para>See <xref linkend="_recording_the_shell_activities_cleanly"/> .</para>
2432 </section>
2433 <section id="_basic_unix_commands">
2434 <title>Basic Unix commands</title>
2435 <para>Let's learn basic Unix commands. Here I use "Unix" in its generic sense. Any Unix clone OSs usually offer equivalent commands. The Debian system is no exception. Do not worry if some commands do not work as you wish now. If <literal>alias</literal> is used in the shell, its corresponding command outputs are different. These examples are not meant to be executed in this order.</para>
2436 <para>Try all following commands from the non-privileged user account.</para>
2437 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
2438 <title>List of basic Unix commands</title>
2439 <tgroup cols="2">
2440 <colspec colwidth="179pt" align="left"/>
2441 <colspec colwidth="570pt" align="left"/>
2442 <thead>
2443 <row>
2444 <entry>
2445 command
2446 </entry>
2447 <entry>
2448 description
2449 </entry>
2450 </row>
2451 </thead>
2452 <tbody>
2453 <row>
2454 <entry>
2455 <literal>pwd</literal>
2456 </entry>
2457 <entry>
2458 display name of current/working directory
2459 </entry>
2460 </row>
2461 <row>
2462 <entry>
2463 <literal>whoami</literal>
2464 </entry>
2465 <entry>
2466 display current user name
2467 </entry>
2468 </row>
2469 <row>
2470 <entry>
2471 <literal>id</literal>
2472 </entry>
2473 <entry>
2474 display current user identity (name, uid, gid, and associated groups)
2475 </entry>
2476 </row>
2477 <row>
2478 <entry>
2479 <literal>file &lt;foo&gt;</literal>
2480 </entry>
2481 <entry>
2482 display a type of file for the file "<literal>&lt;foo&gt;</literal>"
2483 </entry>
2484 </row>
2485 <row>
2486 <entry>
2487 <literal>type -p &lt;commandname&gt;</literal>
2488 </entry>
2489 <entry>
2490 display a file location of command "<literal>&lt;commandname&gt;</literal>"
2491 </entry>
2492 </row>
2493 <row>
2494 <entry>
2495 <literal>which &lt;commandname&gt;</literal>
2496 </entry>
2497 <entry>
2498 , ,
2499 </entry>
2500 </row>
2501 <row>
2502 <entry>
2503 <literal>type &lt;commandname&gt;</literal>
2504 </entry>
2505 <entry>
2506 display information on command "<literal>&lt;commandname&gt;</literal>"
2507 </entry>
2508 </row>
2509 <row>
2510 <entry>
2511 <literal>apropos &lt;key-word&gt;</literal>
2512 </entry>
2513 <entry>
2514 find commands related to "<literal>&lt;key-word&gt;</literal>"
2515 </entry>
2516 </row>
2517 <row>
2518 <entry>
2519 <literal>man -k &lt;key-word&gt;</literal>
2520 </entry>
2521 <entry>
2522 , ,
2523 </entry>
2524 </row>
2525 <row>
2526 <entry>
2527 <literal>whatis &lt;commandname&gt;</literal>
2528 </entry>
2529 <entry>
2530 display one line explanation on command "<literal>&lt;commandname&gt;</literal>"
2531 </entry>
2532 </row>
2533 <row>
2534 <entry>
2535 <literal>man -a &lt;commandname&gt;</literal>
2536 </entry>
2537 <entry>
2538 display explanation on command "<literal>&lt;commandname&gt;</literal>" (Unix style)
2539 </entry>
2540 </row>
2541 <row>
2542 <entry>
2543 <literal>info &lt;commandname&gt;</literal>
2544 </entry>
2545 <entry>
2546 display rather long explanation on command "<literal>&lt;commandname&gt;</literal>" (GNU style)
2547 </entry>
2548 </row>
2549 <row>
2550 <entry>
2551 <literal>ls</literal>
2552 </entry>
2553 <entry>
2554 list contents of directory (non-dot files and directories)
2555 </entry>
2556 </row>
2557 <row>
2558 <entry>
2559 <literal>ls -a</literal>
2560 </entry>
2561 <entry>
2562 list contents of directory (all files and directories)
2563 </entry>
2564 </row>
2565 <row>
2566 <entry>
2567 <literal>ls -A</literal>
2568 </entry>
2569 <entry>
2570 list contents of directory (almost all files and directories, i.e., skip "<literal>..</literal>" and "<literal>.</literal>")
2571 </entry>
2572 </row>
2573 <row>
2574 <entry>
2575 <literal>ls -la</literal>
2576 </entry>
2577 <entry>
2578 list all contents of directory with detail information
2579 </entry>
2580 </row>
2581 <row>
2582 <entry>
2583 <literal>ls -lai</literal>
2584 </entry>
2585 <entry>
2586 list all contents of directory with inode number and detail information
2587 </entry>
2588 </row>
2589 <row>
2590 <entry>
2591 <literal>ls -d</literal>
2592 </entry>
2593 <entry>
2594 list all directories under the current directory
2595 </entry>
2596 </row>
2597 <row>
2598 <entry>
2599 <literal>tree</literal>
2600 </entry>
2601 <entry>
2602 display file tree contents
2603 </entry>
2604 </row>
2605 <row>
2606 <entry>
2607 <literal>lsof &lt;foo&gt;</literal>
2608 </entry>
2609 <entry>
2610 list open status of file "<literal>&lt;foo&gt;</literal>"
2611 </entry>
2612 </row>
2613 <row>
2614 <entry>
2615 <literal>lsof -p &lt;pid&gt;</literal>
2616 </entry>
2617 <entry>
2618 list files opened by the process ID: "<literal>&lt;pid&gt;</literal>"
2619 </entry>
2620 </row>
2621 <row>
2622 <entry>
2623 <literal>mkdir &lt;foo&gt;</literal>
2624 </entry>
2625 <entry>
2626 make a new directory "<literal>&lt;foo&gt;</literal>" in the current directory
2627 </entry>
2628 </row>
2629 <row>
2630 <entry>
2631 <literal>rmdir &lt;foo&gt;</literal>
2632 </entry>
2633 <entry>
2634 remove a directory "<literal>&lt;foo&gt;</literal>" in the current directory
2635 </entry>
2636 </row>
2637 <row>
2638 <entry>
2639 <literal>cd &lt;foo&gt;</literal>
2640 </entry>
2641 <entry>
2642 change directory to the directory "<literal>&lt;foo&gt;</literal>" in the current directory or in the directory listed in the variable "<literal>$CDPATH</literal>"
2643 </entry>
2644 </row>
2645 <row>
2646 <entry>
2647 <literal>cd /</literal>
2648 </entry>
2649 <entry>
2650 change directory to the root directory
2651 </entry>
2652 </row>
2653 <row>
2654 <entry>
2655 <literal>cd</literal>
2656 </entry>
2657 <entry>
2658 change directory to the current user's home directory
2659 </entry>
2660 </row>
2661 <row>
2662 <entry>
2663 <literal>cd /&lt;foo&gt;</literal>
2664 </entry>
2665 <entry>
2666 change directory to the absolute path directory "<literal>/&lt;foo&gt;</literal>"
2667 </entry>
2668 </row>
2669 <row>
2670 <entry>
2671 <literal>cd ..</literal>
2672 </entry>
2673 <entry>
2674 change directory to the parent directory
2675 </entry>
2676 </row>
2677 <row>
2678 <entry>
2679 <literal>cd ~&lt;foo&gt;</literal>
2680 </entry>
2681 <entry>
2682 change directory to the home directory of the user "<literal>&lt;foo&gt;</literal>"
2683 </entry>
2684 </row>
2685 <row>
2686 <entry>
2687 <literal>cd -</literal>
2688 </entry>
2689 <entry>
2690 change directory to the previous directory
2691 </entry>
2692 </row>
2693 <row>
2694 <entry>
2695 <literal>&lt;/etc/motd pager</literal>
2696 </entry>
2697 <entry>
2698 display contents of "<literal>/etc/motd</literal>" using the default pager
2699 </entry>
2700 </row>
2701 <row>
2702 <entry>
2703 <literal>touch &lt;junkfile&gt;</literal>
2704 </entry>
2705 <entry>
2706 create a empty file "<literal>&lt;junkfile&gt;</literal>"
2707 </entry>
2708 </row>
2709 <row>
2710 <entry>
2711 <literal>cp &lt;foo&gt; &lt;bar&gt;</literal>
2712 </entry>
2713 <entry>
2714 copy a existing file "<literal>&lt;foo&gt;</literal>" to a new file "<literal>&lt;bar&gt;</literal>"
2715 </entry>
2716 </row>
2717 <row>
2718 <entry>
2719 <literal>rm &lt;junkfile&gt;</literal>
2720 </entry>
2721 <entry>
2722 remove a file "<literal>&lt;junkfile&gt;</literal>"
2723 </entry>
2724 </row>
2725 <row>
2726 <entry>
2727 <literal>mv &lt;foo&gt; &lt;bar&gt;</literal>
2728 </entry>
2729 <entry>
2730 rename an existing file "<literal>&lt;foo&gt;</literal>" to a new name "<literal>&lt;bar&gt;</literal>" ("<literal>&lt;bar&gt;</literal>" must not exist)
2731 </entry>
2732 </row>
2733 <row>
2734 <entry>
2735 <literal>mv &lt;foo&gt; &lt;bar&gt;</literal>
2736 </entry>
2737 <entry>
2738 move an existing file "<literal>&lt;foo&gt;</literal>" to a new location "<literal>&lt;bar&gt;/&lt;foo&gt;</literal>" (the directory "<literal>&lt;bar&gt;</literal>" must exist)
2739 </entry>
2740 </row>
2741 <row>
2742 <entry>
2743 <literal>mv &lt;foo&gt; &lt;bar&gt;/&lt;baz&gt;</literal>
2744 </entry>
2745 <entry>
2746 move an existing file "<literal>&lt;foo&gt;</literal>" to a new location with a new name "<literal>&lt;bar&gt;/&lt;baz&gt;</literal>" (the directory "<literal>&lt;bar&gt;</literal>" must exist but the directory "<literal>&lt;bar&gt;/&lt;baz&gt;</literal>" must not exist)
2747 </entry>
2748 </row>
2749 <row>
2750 <entry>
2751 <literal>chmod 600 &lt;foo&gt;</literal>
2752 </entry>
2753 <entry>
2754 make an existing file "<literal>&lt;foo&gt;</literal>" to be non-readable and non-writable by the other people (non-executable for all)
2755 </entry>
2756 </row>
2757 <row>
2758 <entry>
2759 <literal>chmod 644 &lt;foo&gt;</literal>
2760 </entry>
2761 <entry>
2762 make an existing file "<literal>&lt;foo&gt;</literal>" to be readable but non-writable by the other people (non-executable for all)
2763 </entry>
2764 </row>
2765 <row>
2766 <entry>
2767 <literal>chmod 755 &lt;foo&gt;</literal>
2768 </entry>
2769 <entry>
2770 make an existing file "<literal>&lt;foo&gt;</literal>" to be readable but non-writable by the other people (executable for all)
2771 </entry>
2772 </row>
2773 <row>
2774 <entry>
2775 <literal>find . -name &lt;pattern&gt;</literal>
2776 </entry>
2777 <entry>
2778 find matching filenames using shell "<literal>&lt;pattern&gt;</literal>" (slower)
2779 </entry>
2780 </row>
2781 <row>
2782 <entry>
2783 <literal>locate -d . &lt;pattern&gt;</literal>
2784 </entry>
2785 <entry>
2786 find matching filenames using shell "<literal>&lt;pattern&gt;</literal>" (quicker using regularly generated database)
2787 </entry>
2788 </row>
2789 <row>
2790 <entry>
2791 <literal>grep -e "&lt;pattern&gt;" *.html</literal>
2792 </entry>
2793 <entry>
2794 find a "&lt;pattern&gt;" in all files ending with "<literal>.html</literal>" in current directory and display them all
2795 </entry>
2796 </row>
2797 <row>
2798 <entry>
2799 <literal>top</literal>
2800 </entry>
2801 <entry>
2802 display process information using full screen, type "<literal>q</literal>" to quit
2803 </entry>
2804 </row>
2805 <row>
2806 <entry>
2807 <literal>ps aux | pager</literal>
2808 </entry>
2809 <entry>
2810 display information on all the running processes using BSD style output
2811 </entry>
2812 </row>
2813 <row>
2814 <entry>
2815 <literal>ps -ef | pager</literal>
2816 </entry>
2817 <entry>
2818 display information on all the running processes using Unix system-V style output
2819 </entry>
2820 </row>
2821 <row>
2822 <entry>
2823 <literal>ps aux | grep -e "[e]xim4*"</literal>
2824 </entry>
2825 <entry>
2826 display all processes running "<literal>exim</literal>" and "<literal>exim4</literal>"
2827 </entry>
2828 </row>
2829 <row>
2830 <entry>
2831 <literal>ps axf | pager</literal>
2832 </entry>
2833 <entry>
2834 display information on all the running processes with ASCII art output
2835 </entry>
2836 </row>
2837 <row>
2838 <entry>
2839 <literal>kill &lt;1234&gt;</literal>
2840 </entry>
2841 <entry>
2842 kill a process identified by the process ID: "&lt;1234&gt;"
2843 </entry>
2844 </row>
2845 <row>
2846 <entry>
2847 <literal>gzip &lt;foo&gt;</literal>
2848 </entry>
2849 <entry>
2850 compress "<literal>&lt;foo&gt;</literal>" to create "<literal>&lt;foo&gt;.gz</literal>" using the Lempel-Ziv coding (LZ77)
2851 </entry>
2852 </row>
2853 <row>
2854 <entry>
2855 <literal>gunzip &lt;foo&gt;.gz</literal>
2856 </entry>
2857 <entry>
2858 decompress "<literal>&lt;foo&gt;.gz</literal>" to create "<literal>&lt;foo&gt;</literal>"
2859 </entry>
2860 </row>
2861 <row>
2862 <entry>
2863 <literal>bzip2 &lt;foo&gt;</literal>
2864 </entry>
2865 <entry>
2866 compress "<literal>&lt;foo&gt;</literal>" to create "<literal>&lt;foo&gt;.bz2</literal>" using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding (better compression than <literal>gzip</literal>)
2867 </entry>
2868 </row>
2869 <row>
2870 <entry>
2871 <literal>bunzip2 &lt;foo&gt;.bz2</literal>
2872 </entry>
2873 <entry>
2874 decompress "<literal>&lt;foo&gt;.bz2</literal>" to create "<literal>&lt;foo&gt;</literal>"
2875 </entry>
2876 </row>
2877 <row>
2878 <entry>
2879 <literal>xz &lt;foo&gt;</literal>
2880 </entry>
2881 <entry>
2882 compress "<literal>&lt;foo&gt;</literal>" to create "<literal>&lt;foo&gt;.xz</literal>" using the Lempel–Ziv–Markov chain algorithm (better compression than <literal>bzip2</literal>)
2883 </entry>
2884 </row>
2885 <row>
2886 <entry>
2887 <literal>unxz &lt;foo&gt;.xz</literal>
2888 </entry>
2889 <entry>
2890 decompress "<literal>&lt;foo&gt;.xz</literal>" to create "<literal>&lt;foo&gt;</literal>"
2891 </entry>
2892 </row>
2893 <row>
2894 <entry>
2895 <literal>tar -xvf &lt;foo&gt;.tar</literal>
2896 </entry>
2897 <entry>
2898 extract files from "<literal>&lt;foo&gt;.tar</literal>" archive
2899 </entry>
2900 </row>
2901 <row>
2902 <entry>
2903 <literal>tar -xvzf &lt;foo&gt;.tar.gz</literal>
2904 </entry>
2905 <entry>
2906 extract files from gzipped "<literal>&lt;foo&gt;.tar.gz</literal>" archive
2907 </entry>
2908 </row>
2909 <row>
2910 <entry>
2911 <literal>tar -xvjf &lt;foo&gt;.tar.bz2</literal>
2912 </entry>
2913 <entry>
2914 extract files from "<literal>&lt;foo&gt;.tar.bz2</literal>" archive
2915 </entry>
2916 </row>
2917 <row>
2918 <entry>
2919 <literal>tar -xvJf &lt;foo&gt;.tar.xz</literal>
2920 </entry>
2921 <entry>
2922 extract files from "<literal>&lt;foo&gt;.tar.xz</literal>" archive
2923 </entry>
2924 </row>
2925 <row>
2926 <entry>
2927 <literal>tar -cvf &lt;foo&gt;.tar &lt;bar&gt;/</literal>
2928 </entry>
2929 <entry>
2930 archive contents of folder "<literal>&lt;bar&gt;/</literal>" in "<literal>&lt;foo&gt;.tar</literal>" archive
2931 </entry>
2932 </row>
2933 <row>
2934 <entry>
2935 <literal>tar -cvzf &lt;foo&gt;.tar.gz &lt;bar&gt;/</literal>
2936 </entry>
2937 <entry>
2938 archive contents of folder "<literal>&lt;bar&gt;/</literal>" in compressed "<literal>&lt;foo&gt;.tar.gz</literal>" archive
2939 </entry>
2940 </row>
2941 <row>
2942 <entry>
2943 <literal>tar -cvjf &lt;foo&gt;.tar.bz2 &lt;bar&gt;/</literal>
2944 </entry>
2945 <entry>
2946 archive contents of folder "<literal>&lt;bar&gt;/</literal>" in "<literal>&lt;foo&gt;.tar.bz2</literal>" archive
2947 </entry>
2948 </row>
2949 <row>
2950 <entry>
2951 <literal>tar -cvJf &lt;foo&gt;.tar.xz &lt;bar&gt;/</literal>
2952 </entry>
2953 <entry>
2954 archive contents of folder "<literal>&lt;bar&gt;/</literal>" in "<literal>&lt;foo&gt;.tar.xz</literal>" archive
2955 </entry>
2956 </row>
2957 <row>
2958 <entry>
2959 <literal>zcat README.gz | pager</literal>
2960 </entry>
2961 <entry>
2962 display contents of compressed "<literal>README.gz</literal>" using the default pager
2963 </entry>
2964 </row>
2965 <row>
2966 <entry>
2967 <literal>zcat README.gz &gt; foo</literal>
2968 </entry>
2969 <entry>
2970 create a file "<literal>foo</literal>" with the decompressed content of "<literal>README.gz</literal>"
2971 </entry>
2972 </row>
2973 <row>
2974 <entry>
2975 <literal>zcat README.gz &gt;&gt; foo</literal>
2976 </entry>
2977 <entry>
2978 append the decompressed content of "<literal>README.gz</literal>" to the end of the file "<literal>foo</literal>" (if it does not exist, create it first)
2979 </entry>
2980 </row>
2981 </tbody>
2982 </tgroup>
2983 </table>
2984 <note>
2985 <para>Unix has a tradition to hide filenames which start with "<literal>.</literal>". They are traditionally files that contain configuration information and user preferences.</para>
2986 </note>
2987 <note>
2988 <para>For <literal>cd</literal> command, see <citerefentry><refentrytitle>builtins</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
2989 </note>
2990 <note>
2991 <para>The default pager of the bare bone Debian system is <citerefentry><refentrytitle>more</refentrytitle><manvolnum>1</manvolnum></citerefentry> which cannot scroll back. By installing the <literal>less</literal> package using command line "<literal>apt-get install less</literal>", <citerefentry><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry> becomes default pager and you can scroll back with cursor keys.</para>
2992 </note>
2993 <note>
2994 <para>The "<literal>[</literal>" and "<literal>]</literal>" in the regular expression of the "<literal>ps aux | grep -e "[e]xim4*"</literal>" command above enable <literal>grep</literal> to avoid matching itself. The "<literal>4*</literal>" in the regular expression means 0 or more repeats of character "<literal>4</literal>" thus enables <literal>grep</literal> to match both "<literal>exim</literal>" and "<literal>exim4</literal>". Although "<literal>*</literal>" is used in the shell filename glob and the regular expression, their meanings are different. Learn the regular expression from <citerefentry><refentrytitle>grep</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
2995 </note>
2996 <para>Please traverse directories and peek into the system using the above commands as training. If you have questions on any of console commands, please make sure to read the manual page.</para>
2997 <para>For example, try the following</para>
2998 <screen>$ man man
2999 $ man bash
3000 $ man builtins
3001 $ man grep
3002 $ man ls</screen>
3003 <para>The style of man pages may be a little hard to get used to, because they are rather terse, particularly the older, very traditional ones. But once you get used to it, you come to appreciate their succinctness.</para>
3004 <para>Please note that many Unix-like commands including ones from GNU and BSD display brief help information if you invoke them in one of the following ways (or without any arguments in some cases).</para>
3005 <screen>$ &lt;commandname&gt; --help
3006 $ &lt;commandname&gt; -h</screen>
3007 </section>
3008 </section>
3009 <section id="_the_simple_shell_command">
3010 <title>The simple shell command</title>
3011 <para>Now you have some feel on how to use the Debian system. Let's look deep into the mechanism of the command execution in the Debian system. Here, I have simplified reality for the newbie. See <citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry> for the exact explanation.</para>
3012 <para>A simple command is a sequence of components.</para>
3013 <orderedlist>
3014 <listitem>
3015 <para>
3016 Variable assignments (optional)
3017 </para>
3018 </listitem>
3019 <listitem>
3020 <para>
3021 Command name
3022 </para>
3023 </listitem>
3024 <listitem>
3025 <para>
3026 Arguments (optional)
3027 </para>
3028 </listitem>
3029 <listitem>
3030 <para>
3031 Redirections (optional: <literal>&gt;</literal> , <literal>&gt;&gt;</literal> , <literal>&lt;</literal> , <literal>&lt;&lt;</literal> , etc.)
3032 </para>
3033 </listitem>
3034 <listitem>
3035 <para>
3036 Control operator (optional: <literal>&amp;&amp;</literal> , <literal>||</literal> , &lt;newline&gt; , <literal>;</literal> , <literal>&amp;</literal> , <literal>(</literal> , <literal>)</literal> )
3037 </para>
3038 </listitem>
3039 </orderedlist>
3040 <section id="_command_execution_and_environment_variable">
3041 <title>Command execution and environment variable</title>
3042 <para>Values of some <ulink url="http://en.wikipedia.org/wiki/Environment_variable">environment variables</ulink> change the behavior of some Unix commands.</para>
3043 <para>Default values of environment variables are initially set by the PAM system and then some of them may be reset by some application programs.</para>
3044 <itemizedlist>
3045 <listitem>
3046 <para>
3047 The display manager such as <literal>gdm3</literal> resets environment variables.
3048 </para>
3049 </listitem>
3050 <listitem>
3051 <para>
3052 The shell in its start up codes resets environment variables in "<literal>~/bash_profile</literal>" and "<literal>~/.bashrc</literal>".
3053 </para>
3054 </listitem>
3055 </itemizedlist>
3056 </section>
3057 <section id="_literal_lang_literal_variable">
3058 <title>"<literal>$LANG</literal>" variable</title>
3059 <para>The full locale value given to "<literal>$LANG</literal>" variable consists of 3 parts: "<literal>xx_YY.ZZZZ</literal>".</para>
3060 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
3061 <title>3 parts of locale value</title>
3062 <tgroup cols="2">
3063 <colspec colwidth="70pt" align="left"/>
3064 <colspec colwidth="504pt" align="left"/>
3065 <thead>
3066 <row>
3067 <entry>
3068 locale value
3069 </entry>
3070 <entry>
3071 meaning
3072 </entry>
3073 </row>
3074 </thead>
3075 <tbody>
3076 <row>
3077 <entry>
3078 <literal>xx</literal>
3079 </entry>
3080 <entry>
3081 <ulink url="http://en.wikipedia.org/wiki/ISO_639">ISO 639 language codes (lower case) such as "en"</ulink>
3082 </entry>
3083 </row>
3084 <row>
3085 <entry>
3086 <literal>YY</literal>
3087 </entry>
3088 <entry>
3089 <ulink url="http://en.wikipedia.org/wiki/ISO_3166-3">ISO 3166 country codes (upper case) such as "US"</ulink>
3090 </entry>
3091 </row>
3092 <row>
3093 <entry>
3094 <literal>ZZZZ</literal>
3095 </entry>
3096 <entry>
3097 <ulink url="http://en.wikipedia.org/wiki/Codeset">codeset, always set to "UTF-8"</ulink>
3098 </entry>
3099 </row>
3100 </tbody>
3101 </tgroup>
3102 </table>
3103 <para>For language codes and country codes, see pertinent description in the "<literal>info gettext</literal>".</para>
3104 <para>For the codeset on the modern Debian system, you should always set it to <emphasis role="strong"><literal>UTF-8</literal></emphasis> unless you specifically want to use the historic one with good reason and background knowledge.</para>
3105 <para>For fine details of the locale configuration, see <xref linkend="_the_locale"/>.</para>
3106 <note>
3107 <para>The "<literal>LANG=en_US</literal>" is not "<literal>LANG=C</literal>" nor "<literal>LANG=en_US.UTF-8</literal>". It is "<literal>LANG=en_US.ISO-8859-1</literal>" (see <xref linkend="_basics_of_encoding"/>).</para>
3108 </note>
3109 <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
3110 <title>List of locale recommendations</title>
3111 <tgroup cols="2">
3112 <colspec