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