summaryrefslogtreecommitdiffstats
path: root/unix-primer/C/unix-primer.sgml
blob: dac4f42f862031b45a43be77018b861e81c1e00f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
<!DOCTYPE article PUBLIC "-//GNOME//DTD DocBook PNG Variant V1.1//EN"[
]>
<article id="index"> 
 
  <artheader> 
    <title> If you are new to Linux/UNIX</title>
    <copyright>
      <year>2000</year>
      <holder>Alexander Kirillov</holder>
    </copyright>

      <legalnotice id="legalnotice">
      <para>
        Permission is granted to copy, distribute and/or modify this
        document under the terms of the <ulink type="help"
        url="gnome-help:fdl"><citetitle>GNU Free Documentation
        License</citetitle></ulink>, Version 1.1 or any later version
        published by the Free Software Foundation with no Invariant
        Sections, no Front-Cover Texts, and no Back-Cover Texts. You
        may obtain a copy of the <citetitle>GNU Free Documentation
        License</citetitle> from the Free Software Foundation by
        visiting <ulink type="http" url="http://www.fsf.org">their Web
        site</ulink> or by writing to: Free Software Foundation, Inc.,
        59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
      </para>
	
	<para>
	  Many of the names used by companies to distinguish their
	  products and services are claimed as trademarks. Where those
	  names appear in any GNOME documentation, and those
	  trademarks are made aware to the members of the GNOME
	  Documentation Project, the names have been printed in caps
	  or initial caps.
	</para>
      </legalnotice>
    </artheader>
<sect1 id="introduction"> 
    <title>Introduction</title>
 
  <para> One of the goals of GNOME is to make your system easy to use,
    without requiring you to learn the technical details about your
    operating system.  However, there are some basic UNIX notions that
    you have to be familiar with even while using the easy graphical
    interface provided by GNOME. For the convenience of new users,
    these basics are collected in this document. If you need further
    information on UNIX, you should read the documentation which came
    with your system; there are also a number of books and on-line
    guides available for all versions of UNIX.
  </para>

  <para> The following guide applies to all versions of UNIX and
    UNIX-like operating systems, including both the commercial Unices
    such as <systemitem>Solaris</systemitem> and open-source operating
    systems such as <systemitem>FreeBSD</systemitem> and
    <systemitem>Linux</systemitem>. Some of the material here is based
    on <citetitle>Linux Installation and Getting Started</citetitle>
    guide, by Matt Welsh, Phil Hughes, David Bandel, Boris Beletsky,
    Sean Dreilinger, Robert Kiesling, Evan Liebovitch, and Henry
    Pierce. The guide is available for download or online viewing from
    the <ulink url="http://www.linuxdoc.org" type="http">Linux
    Documentation Project</ulink> or from the <ulink
    url="http://www.oswg.org">Open Source Writers Group</ulink>.
  </para>
  </sect1>

 <sect1 id="new-users">
    <title>Users</title> 
    <para> UNIX is a multiuser operating system: it
      was designed to allow many users to work on the same computer,
      either simultaneously (using several terminals or network
      connections) or in turns. Under UNIX, to identify yourself to
      the system, you must log in, which entails entering your
      <emphasis>login name</emphasis> (the name the system uses to identify
      you) and your <emphasis>password</emphasis>, which is your personal key
      for logging in to your account. Because only you know your
      password, no one else can log in to the system under your user
      name. Usually people choose their first or last name or some
      variation of it as their login name, so that if your real name
      is Sasha Beilinson, your login might be <systemitem>sasha</systemitem>.
    </para>
    <para> Each user has a separate place to keep his files (called
      his <emphasis>home directory</emphasis>). UNIX has a system of
      permissions (see <xref linkend="permissions">), so that on a
      properly configured UNIX system a user can't change other users'
      or system files. This also allows every user to customize
      various aspects of the system &mdash; in particular, GNOME
      behavior &mdash; for himself, without affecting other users.
    </para>
    <para> On any UNIX system there is also a special user, called
      <emphasis>system administrator</emphasis>, with the login name
      <systemitem>root</systemitem>. He has <emphasis>full</emphasis>
      control over the system &mdash; including full access to all the
      system and users' files. He has the authority to change the
      passwords of existing users and add new users, install and
      uninstall software, and so on. The system administrator is
      usually the person responsible for proper functioning of the
      system, so if you have some problems, you should ask him.
    </para>
    <important>
      <title>IMPORTANT</title>
      <para>
	Even if you are the only user on your computer (for example,
	if the computer is your personal workstation), so that you are
	also the system administrator, it is important that you create
	a user account and use it for daily work, logging in as root
	only when necessary for system maintenance. Because root can
	do anything, it is easy to make mistakes that have
	catastrophic consequences.  Picture the root account as a
	magic hat that gives you lots of power, with which you can, by
	waving your hands, create or destroy entire cities.  Because
	it is easy to wave your hands in a destructive manner, it is
	not a good idea to wear the magic hat when it is not needed,
	despite the wonderful feeling.
      </para>
    </important>
  </sect1>
  <sect1 id="new-file">
    <title>Files and filenames</title>
    <para>
      Under most operating systems (including UNIX), there is the
      concept of a <emphasis>file</emphasis>, which is just a bundle of
      information given a name (called a
      <emphasis>filename</emphasis>). Examples of files might be
      your history term paper, an e-mail message, or an actual
      program that can be executed. Essentially, anything saved on
      disk is saved in an individual file.
    </para>
    <sect2 id="new-filenames">
      <title>Filenames</title>
      <para>
	Files are identified by their filenames. For example, the file
	containing your conference talk might be saved with the filename
	<filename>talk.txt</filename>. There is no standard format for file
	names as there is under MS-DOS and some other operating systems; in
	general, a filename can contain any character (except the /
	character&ndash;see the discussion of path names below) and is
	limited to 256 characters in length.
      </para>
      <important>
	<title>IMPORTANT</title>
	<para>
	  Unlike MS-DOS, the filenames in UNIX are case-sensitive:
	  <filename>myfile.txt</filename> and
	  <filename>MyFile.txt</filename> are considered as two
	  different files.
	</para>
      </important>
      <para>
	You should also be aware of several UNIX conventions; while they are
	not mandatory, it is usually a good idea to follow them.
	<itemizedlist>
	  <listitem>
	    <para> It is customary to use the format
	      <filename>filename.extension</filename> for filenames,
	      where the extension indicates the file type; for
	      example, the extension <filename>txt</filename> is
	      usually used for plain text files, while the extension
	      <filename>jpeg</filename> is used for graphics in JPEG
	      format, and so on. In particular, the <application>GNOME
	      File Manager</application>
	      (<application>Nautilus</application>) uses extensions to
	      determine file type. You can view or change file
	      extensions recognized by
	      <application>GNOME</application> by selecting the
	      section <menuchoice><guimenu>Document Handlers</guimenu>
	      <guimenuitem>MIME types</guimenuitem> </menuchoice> in
	      <application>GNOME Control Center</application>.  Note
	      that the standard convention in UNIX is that the
	      <emphasis>executables</emphasis> (i.e., the program
	      files) have no extension at all.
            </para>
          </listitem>
	  
	  <listitem>
	    <para> Files and directories whose names begin with a dot
	      (.) are usually <emphasis>configuration
		files</emphasis>, that is, files which keep settings and
	      preferences for various applications. For example, GNOME
	      keeps all its settings in various files in the directories
	      <filename>.gnome</filename> and
	      <filename>.gnome-desktop</filename> in the user's home
	      directory. Since most of the time you do not need to
	      edit these files manually, or even know their precise
	      names and locations, <application>Nautilus</application>
	      usually doesn't show these files. You can change this
	      setting as described in <ulink type="help"
	      url="gnome-help:nautilus">Nautilus manual</ulink>. 
	    </para>
	  </listitem>
	  
	  <listitem> 
	    <para> Files with names ending with tilde (~) are
	      usually backup files created by various
	      applications. For example, when you edit a file
	      <filename> myfile.txt</filename> with
	    <application>emacs</application>, it 
	      saves the previous version in the file
	      <filename>myfile.txt~</filename>.
	    </para>
	  </listitem>
	</itemizedlist>
      </para>
    </sect2>
    <sect2 id="new-wildcards">
      <title> Wildcards</title> 

      <para>When entering commands from the command line, you can use
	so-called <emphasis>wildcards</emphasis> instead of an exact
	filename. The most common wildcard is *, which matches any
	sequence of symbols (including an empty string). For example,
	the command <command>ls *.txt</command> will list all the files with
	the extension <filename>txt</filename>, and the command <command>rm
	  chapter*</command> will remove all files with the names starting with
	<filename>chapter</filename> (<command>ls</command> and
	<command>rm</command> are UNIX 
	commands for listing and removing files). Another useful
	wildcard is ?, which matches any single symbol: for example,
	<command>rm chapter?.txt</command> will remove files
	<filename>chapter1.txt, chapter2.txt</filename> , but not
	<filename>chapter10.txt</filename>
      </para>
      <para>Most new GNOME users prefer using the <application>GNOME
	  File Manager</application> for operations with files, rather
	  than working from the command line. Wildcards can also be
	  used in  <application>Nautilus</application> in the file
	  selection and view filter dialogs.  </para>
    </sect2>

    <sect2 id="quoting">
      <title>Using spaces, commas, etc. in file names</title>
      <para>
	As was mentioned above, a file name may contain not only
	letters and numbers, but also spaces, commas, etc. &mdash; any
	characters other than slash (/). However, if you are using
	commands typed on the command line, you should be careful when
	dealing with such files. To avoid problems, it is advised that
	you enclose  filenames that contain anything other than
	letters, numbers, and dots,  in single quotes: to delete file
	<filename>My File</filename>, you should type <command>rm 'My
	File'</command> rather than <command>rm My
	File</command>.
      </para>
      <para>
	Of course, if you are only using graphical tools such as GNOME
	File Manager, than you do not  need to worry about this: to
	delete file <filename>My File</filename>, just drag it to the
	trash can.
      </para>
    </sect2>

  </sect1>
  <sect1 id="new-dirs">
    <title>Directories and paths</title> 
    <sect2 id="new-dirstruct">
      <title>Directory structure</title>
      <para>
	Now, let's discuss the concept of directories. A
	<emphasis>directory</emphasis> is a collection of files. It
	can be thought of as a <quote>folder</quote> that contains
	many different files. Directories are given names, with which
	they can be identified. Furthermore, directories are
	maintained in a tree-like structure; that is, directories may
	contain other directories. The top level directory is called
	the <quote>root directory</quote> and denoted by
	<filename>/</filename>; it contains all the files in your
	system.
      </para>
      <sect3 id="new-path">
	<title>Pathnames</title>
	<para>
	  A <emphasis>pathname</emphasis> is a file's <quote>full
	  name</quote>; it contains not only filename but also its
	  location. It is made up of the filename, preceded by the
	  name of the directory containing that file. This, in turn,
	  is preceded by the name of directory containing
	  <emphasis>that directory</emphasis>, and so on. A typical
	  pathname may look like
	  <filename>/home/sasha/talk.txt</filename> which refers to
	  the file <filename>talk.txt</filename> in the directory
	  <filename>sasha</filename> which in turn is a subdirectory
	  in <filename>/home</filename>.
	</para>
	<para>
	  As you can see, the directory and filename are separated by
	  a single slash (/). For this reason, filenames themselves
	  cannot contain the / character.  MS-DOS users will find this
	  convention familiar, although in the MS-DOS world the
	  backslash (\) is used instead. The directory that contains a
	  given subdirectory is known as the <emphasis>parent
	  directory</emphasis>. Here, the directory
	  <filename>home</filename> is the parent of the directory
	  <filename>sasha</filename>.
	</para>
	<para>
	  Each user has a home directory, which is the directory set aside for
	  that user to store his or her files.  Usually, user home directories
	  are contained under <filename>/home</filename>, and are named for the
	  user owning that directory, so that the home directory of user
	  <systemitem>sasha</systemitem> would be 
	  <filename>/home/sasha</filename>.
	</para>
      </sect3>
    </sect2>
    <sect2 id="new-relative"> 
      <title>Relative directory names</title>
      <para>
	At any moment, commands that you enter are assumed to be
	<emphasis>relative</emphasis> to your current working
	directory. You can think of your working directory as the
	directory in which you are currently
	<quote>located</quote>. When you first log in, your working
	directory is set to your home directory &mdash; for user
	sasha, it would be <filename>/home/sasha</filename>. Whenever
	you refer to a file, you may refer to it in relationship to
	your current working directory, rather than specifying the
	full pathname of the file.
      </para>
      <para>
	For example, if your current directory is
	<filename>/home/sasha</filename>, and you have a file there called
	<filename>talk.txt</filename>, you can refer to it just by its file
	name: a command like <command>emacs talk.txt</command> issued from the
	directory <filename>/home/sasha</filename> is equivalent to
	<command>emacs /home/sasha/talk.txt</command>
	(<application>emacs</application> is an extremely powerful editor for
	text files; new users may prefer something simpler, such as
	<application>gnotepad</application>, but for power user,
	<application>emacs</application> is indispensable).
      </para>


      <para>
	Similarly, if, in <filename>/home/sasha</filename> you have a
	subdirectory called <filename>papers</filename> and, in that
	subdirectory, a file called <filename>fieldtheory.txt</filename>, you
	can refer to it as <filename>papers/fieldtheory.txt</filename>.
      </para>
      <para> If you begin a filename (like
	<filename>papers/fieldtheory.txt</filename>) with a character
	other than /, you're referring to the file in terms relative
	to your current working directory. This is known as a relative
	pathname.  On the other hand, if you begin a filename with a
	/, the system interprets this as a full pathname &mdash; that
	is, a pathname that includes the entire path to the file,
	starting from the root directory, /. Use of the full pathname
	is known as an <emphasis>absolute pathname</emphasis>.
      </para>
    </sect2>
    <sect2 id="new-path-conv">
      <title>Pathname conventions</title> 
      <para>
	Here are some standard conventions you can use in paths: 
      </para>
      <para>
	<filename>~/</filename> &mdash; user's home directory
      </para>
      <para>
	<filename>./</filename>  &mdash; current working directory
      </para>
      <para>
	<filename>../</filename>  &mdash; parent of the current directory
      </para>
      <para>
	For example, if sasha's current directory is
	<filename>/home/sasha/papers</filename>, he can refer to the file
	<filename>/home/sasha/talk.txt</filename> as
	<filename>~/talk.txt</filename> or as <filename>../talk.txt</filename>.
      </para>
    </sect2>
  </sect1>
  <sect1 id="permissions">
    <title>Permissions</title>
    <para>
      Every file on your system has an <emphasis>owner</emphasis> &mdash; one
      of the users (usually the one who created this file), and a system of
      <emphasis>permissions</emphasis>, which regulate access to this
      file.
    </para>
    <para>
      For ordinary files, there are 3 types of access permissions:
      read, write, and execute (the latter only makes sense for
      executable files). They can be set independently for 3
      categories of users: the file owner, the users in the group
      owning the file, and everyone else. Discussion of groups of
      users goes beyond the scope of this document; the other two
      categories are self-explanatory.  <!--Which groups of users? I
      don't think the other two categories are self-explanatory. Would
      help if there was some exposition here which explicitly states
      who belongs where.-->So, if the permissions on a file
      <filename>/home/sasha/talk.txt</filename> are set to read and
      write for user sasha, who is the file owner, and read only for
      everyone else, only sasha will be able to modify this file.
      <!--How about adding something in parentheses here, like (Since
      sasha created the file <filename>talk.txt</filename>, sasha has
      the widest range of rights to access the file.)... or something
      like that?-->
    </para>

    <para>
      All newly created files carry some standard permissions, usually
      read/write for user and read only for everyone else. You can
      view the permissions using the GNOME File Manager, by
      right-clicking on the file, choosing
      <guimenuitem>Properties</guimenuitem> in the pop-up menu, and
      then the <guilabel>Permissions</guilabel> tab. Using this
      dialog, you can also change the permissions &mdash; just click
      on a square representing the permission to toggle it.  Of
      course, only the file owner or the system administrator can
      change the permissions of a file. Advanced users can also change
      the default file permissions which are assigned to newly created
      files&mdash;see the manual pages for your default shell (usually
      <command>bash</command>, <command>csh</command> or
      <command>tcsh</command>) and look for the command
      <command>umask</command>.
    </para>

    <para>
      A file can also have some special permission properties such as
      UID, GID, and <quote>sticky</quote> bit. They are for advanced
      users only &mdash; do not change them unless you know what you
      are doing. (If you are curious: these permissions are typically
      used on executable files to allow the user to execute
      <emphasis>some</emphasis> commands which read or modify files to
      which the user himself doesn't have access.)
    </para>

    <para> Similar to files, the directories also have
      permissions. Again, there are 3 possible permissions: read,
      write, and execute. However, they have different meaning:
      namely, <quote>read</quote> permission for a directory means
      permission to list the contents of the directory or search for a
      file; <quote>write</quote> means permission to create and remove
      files in the directory, and <quote>execute</quote> means
      permission to access files in the directory.
    </para>
    <para>
      Note that the permissions granted to a file depend on the
      permissions of the directory in which the file is located: in
      order to be able to read a file, a user needs to have the read
      permission for the file itself and <quote>execute</quote>
      permission for the directory that contains it. So, if user sasha
      doesn't want anybody else to see his files, he can achieve this
      by removing the execute permission on his home directory for all
      other users. This way, no one but himself (and, of course, root)
      will be able to read any of his files, no matter what the
      permissions of individual files are.
    </para>
    <para> Detailed explanation of the permission system can be found,
      for example, in the <ulink type="info" url="info:fileutils">info
      page</ulink> for the GNU <citetitle>File Utilities</citetitle>
      package.
      </para>
  </sect1>

  <sect1 id="symlinks">
    <title>Symbolic links</title>
    <para>
      In addition to regular files, UNIX also has special files called
      <emphasis>symbolic links</emphasis> (or
      <emphasis>symlinks</emphasis> for short). These files do not
      contain any data; instead, they are just
      <quote>pointers</quote>, or <quote>shortcuts</quote> to other
      files. For example, sasha can have a symlink named
      <filename>ft.txt</filename> pointing to the file
      <filename>papers/fieldtheory.txt</filename>; this way, when a
      program tries to access the file <filename>ft.txt</filename>,
      the file <filename>papers/fieldtheory.txt</filename> will be
      opened instead. As you can see from this example, the symlink
      and the target file can have different names and be located in
      different directories.
    </para>
    <para> Note that deleting, moving, or renaming the symlink file
      has no effect on the target file: if sasha tries to delete the
      file <filename>ft.txt</filename>, it is the symlink that will
      be deleted, and the file
      <filename>papers/fieldtheory.txt</filename> will remain
      unchanged.  Also, the permissions of the symlink are
      meaningless: it is the permissions of the target file that
      determine whether a user has the access to it.
    </para>

    <para> Symlinks can also point to directories.  For example, on
      the GNOME FTP server (<systemitem>ftp.gnome.org</systemitem>),
      there is a file
      <filename>/pub/GNOME/stable/releases/october-gnome</filename>,
      which is actually a  symlink to directory
      <filename>/pub/GNOME/stable/releases/gnome-1.0.53</filename>
      &mdash; as one would expect, since <quote>October GNOME</quote>
      is  just another name for 1.0.53 release
      of GNOME.  
    </para>
  </sect1>
  <sect1 id="new-mount">
    <title>Mounting and unmounting drives</title>
    <para>
      As we mentioned earlier, the directories on a UNIX system are
      organized in a tree, with the top level directory being
      <filename>/</filename>. Unlike some other operating systems such as
      MS-DOS, there are no special names for files on your floppy disk or
      CD-ROM: <emphasis>all</emphasis> the files accessible to your system
      must appear in the main directory tree starting with
      <filename>/</filename>.
    </para>
    <para>
      Thus, before you can access files on a floppy diskette or a
      CD-ROM, you must give to your system a command to incorporate
      the contents of this diskette into the main directory tree,
      which is referred to as <emphasis>mounting</emphasis> the
      diskette. You can think of it as the software analog of
      connecting the drive to your system.  Typically the contents of
      the CD-ROM will appear under the name
      <filename>/mnt/cdrom</filename>; the floppy diskette under
      <filename>/mnt/floppy</filename> (these are called the
      <emphasis>mount points</emphasis> and are defined in the special
      configuration file, <filename>/etc/fstab</filename>). Accessing
      a drive in this fashion doesn't mean that the system will copy
      all the files from the CD to the directory
      <filename>/mnt/cdrom</filename>. Instead, it means that the
      directory <filename>/mnt/cdrom</filename>
      <emphasis>represents</emphasis> the CD-ROM: When a program tries
      to access, say, a file called
      <filename>/mnt/cdrom/index.html</filename>, the system will look
      for file <filename>index.html</filename> on the CD-ROM.
    </para>
    <para>
      So, in short: before you can use files on a drive, you must
      <quote>mount</quote> it. Similarly, <emphasis>before removing
      the disk from the drive, you must unmount it.</emphasis>
    </para>
    <para>
      When using GNOME, you usually do not have to worry about
      mounting and unmounting: GNOME scans the appropriate
      configuration file and places the icons for all drives on your
      desktop. Double-clicking on any of these icons automatically
      mounts the corresponding drive (if it was not already mounted)
      and starts the file manager in the appropriate directory.
      Similarly, if you right-click on the drive icon and choose the
      command <guimenuitem>Eject device</guimenuitem> from the pop-up
      menu, GNOME automatically unmounts it before ejecting. You can
      also mount/unmount a drive by right-clicking on its icon on the
      desktop and choosing <guimenuitem>Mount device</guimenuitem> or
      <guimenuitem>Unmount device</guimenuitem> from the pop-up menu,
      or by using the disk mount applet.
    </para>
    <para>
      Note that you can't unmount a drive if it is being used by some
      program; for example, if you have a terminal windows open in a
      directory on the drive you're trying to unmount. So, if you get
      the error message <quote>Device busy</quote> while trying to
      unmount a drive, make sure that none of your open applications
      is accessing a file or directory on this drive.
    </para>
    <para>
      However, GNOME cannot prevent you from ejecting the disk using the
      physical eject button on the drive itself &mdash; in this case,
      <emphasis>it is your responsibility to unmount the drive</emphasis>
      before doing so. For CD and Zip drives, the system blocks the eject
      button on the drive while the drive is mounted; for floppy drives this
      is technically impossible.
    </para>

    <important>
      <title>IMPORTANT</title>
      <para>
	If you eject a floppy  disk using the eject button on the drive without
	first unmounting it, you may lose your data!
      </para>
    </important>

    <para> Some systems are running special programs such as
      <application>supermount</application> or
      <application>magicdev</application>
      which automatically mount a drive when a disk is inserted and unmount a
      drive if it hasn't been used for a specified period of time. In
      this case, you will probably never need to worry about
      mounting/unmounting drives yourself; you don't even need to read
      this section. 
    </para>
    <para>
      Allowing users to mount and unmount drives carries some security
      risks, so many multi-user systems are configured so that only
      root can mount or unmount drives. This is the most probable
      cause of error messages you may be getting while trying to mount
      a drive. In this case, discuss this matter with your system
      administrator.
    </para>
    <para>
      If the computer is your personal workstation or home computer
      and you are not worried about security, you can give mount
      permission to ordinary users. The easiest way to allow this is
      to use the application
      <application><emphasis>linuxconf</emphasis></application> (which
      can only be run by root).  Just select the drive you want to
      access in the <guilabel>Access local drive</guilabel> section.
      In the <guilabel>Options</guilabel> tab select the
      <guilabel>User Mountable</guilabel> option.  Your drive will now
      be mountable by users.
    </para>
    <para>
      If <application><emphasis>linuxconf</emphasis></application> is
      not available, then you must manually edit the file
      <filename>/etc/fstab</filename> to include user access. This is
      done by adding the <quote>user</quote> attribute to the
      drive. For example:
    </para>
    <para>
      If your <filename>fstab</filename> file contains a line like
      this:
    </para>
      <programlisting>
/dev/cdrom /mnt/cdrom iso9660 exec,dev,ro,noauto 0 0
      </programlisting>
      <para>
      add the word <quote>user</quote> to the fourth column:
    </para>
    <programlisting>
/dev/cdrom /mnt/cdrom iso9660 user,exec,dev,ro,noauto 0 0
    </programlisting>
  </sect1>

  <sect1 id="devices">
    <title>Drives and devices</title>
    <para>
      Under UNIX, the word <quote>device</quote> is used for all
      peripheral devices connected to your computer; this includes
      hard drives, floppy and CD-ROM drives, audio and video cards,
      serial and parallel ports, and much more. Each device has a
      name, such as <filename>/dev/hda</filename>. The most common
      device names are listed below (for Linux; other varieties of
      UNIX may use slightly different device names).
    </para>
    <itemizedlist>
      <listitem><para> <filename>/dev/hd*</filename> (where *=a,b,c,
	  &hellip;): these are IDE devices, such as hard drives,
	  CD-ROM drives and ZIP drives. <filename>/dev/hda</filename>
	  denotes the master drive on the first IDE controller
	  (usually your first hard drive, <filename>C:</filename>
	  under Windows), <filename>/dev/hdb</filename> is the slave
	  drive on the fist controller (this can be a second hard
	  drive or a CD-ROM), and so on. See also the <link
	  linkend="zippartition">note</link> below about ZIP drives.
	  </para></listitem>

      <listitem><para>
	  <filename>/dev/sd*</filename> (where *=a,b,c, &hellip;):
	  these are SCSI devices, usually hard drives. 
	</para></listitem>
    </itemizedlist>

    <note>
      <title>NOTE</title> 
      <para>If the acronyms IDE and SCSI are new to you, here is a
      brief explanation: there are two types of interfaces for hard
      drives and other similar devices: IDE (and its cousins such as
      EIDE, ATAPI, etc.) and SCSI. SCSI provides better performance,
      but is more expensive, so it is only used on
      servers. If you are not sure what kind of drives you have, most
      probably it is IDE. </para>
    </note> 
    <itemizedlist>
      <listitem><para>
	  <filename>/dev/fd*</filename> (where *=0,1, etc) are floppy
	  drives; <filename>/dev/fd0</filename> is the first drive (it
	  corresponds to <filename>A:</filename> under Windows),
	  <filename>/dev/fd1</filename> is the second
	  (<filename>B:</filename>), etc. 
	</para>
      </listitem>
      <listitem><para>
	  <filename>/dev/lp*</filename> (where *=0,1, etc) are
	  parallel ports; most commonly, these ports are used to
	  connect a printer to the
	  computer. <filename>/dev/lp0</filename> corresponds to
	  <filename>LPT1</filename> under Windows,
	  <filename>/dev/lp1</filename> to <filename>LPT2</filename>,
	  etc.  
	</para>
      </listitem>
      <listitem><para> <filename>/dev/ttyS*</filename> (where *=0,1,
	  etc) are serial ports; these ports are commonly used for
	  connecting a mouse or a
	  modem. <filename>/dev/ttyS0</filename> corresponds to
	  <filename>COM1</filename> under Windows,
	  <filename>/dev/ttyS1</filename> to <filename>COM2</filename>,
	  etc.
	</para>
      </listitem>
      <listitem><para> 
	  <filename>/dev/audio</filename> and
	  <filename>/dev/dsp</filename> &mdash; these two device
	  names are used for your audio card (they are not equivalent,
	  since they are used for different types of audio files). 
	</para>
	</listitem>
    </itemizedlist>
    <para>
      In addition, it is a common practice to have symlinks
      <filename>/dev/floppy, /dev/modem</filename> and
      <filename>/dev/cdrom</filename> pointing to the actual device
      name corresponding to your floppy drive, modem, and CD-ROM drive
      respectively.
    </para>
    <para>
      You rarely need to use these device names. In particular, if you
      want to access a file on a drive, you do not use the device name
      (such as <filename>/dev/fd0</filename>); instead, you first
      mount the device so that its contents shows as a subdirectory
      (for example, <filename>/mnt/floppy</filename>) in the main
      directory tree, and then use this directory for accessing
      files; see <xref linkend="new-mount"> for more information. About
      the only time when you actually need to use the device names is
      when you are configuring some newly installed program. For
      example, a fax program can ask you for the device name for your
      modem (in which case you can either give it the actual device
      name, such as <filename>/dev/ttyS1</filename>, or just use the
      symlink <filename>/dev/modem</filename>).
    </para>
    <para> And just for fun: there is also a device
    <filename>/dev/null</filename> which acts as a <quote>black
    hole</quote>: you can send to it any information, and it never
    returns. So if you do not want to be bothered by error messages,
    re-direct them to <filename>/dev/null</filename> -:).
    </para>

    <sect2 id="partitions">
      <title>Partitions</title>
      <para>
	Note that it is possible to subdivide a hard drive (or a
	similar device) into parts which for all practical purposes
	behave as independent disks, even though physically they
	reside on the same disk. These parts are called
	<quote>partitions</quote> (under Windows, the name
	<quote>logical disk</quote> is used). For example, you can
	partition your hard drive into several partitions, and install
	different operating systems in different partitions; you can
	reformat each partition independently of the others. This
	partitioning of the hard drive is usually done during the
	installation of the operating system; refer to your
	installation guide for more information.
      </para>
      <para> 
	If your hard drive has been partitioned then each partition
	is considered as a separate device. For example, if your hard
	drive is <filename>/dev/hda</filename>, then the first
	partition on this drive would be referred to as
	<filename>/dev/hda1</filename>, the second as
	<filename>/dev/hda2</filename>, and so on. 
      </para>
      <warning id="zippartition">
	<title> Partitioning of ZIP disks</title> 

	<para> For reasons unknown to us, the pre-formatted
	  ZIP disks sold in stores or formatted using Iomega's ZIP
	  tools under Windows are partitioned in a strange way:
	  they have only one partition (of Windows type, of course),
	  but this partition has number 4. Thus, if your ZIP drive is
	  <filename>/dev/hdc</filename>, the correct device name you
	  should use for such disks is <filename>/dev/hdc4</filename>.
	</para>
      </warning>
    </sect2>
  </sect1>
  <sect1 id="X11"> 
    <title>Graphical user interface: X Window System, window
      managers, and desktop environments.</title>
    <para>
      UNIX is a modular system: it consists of many components so that
      a user (or system administrator) can choose those components he
      needs.  In particular, there are several layers of software
      responsible for graphical user interface. These layers are: X
      Window System, window managers, and desktop environment.
    </para>
    <para> <emphasis>X Window System</emphasis> (also known as X, or
      X11) is the component of UNIX systems responsible for virtually
      all basic graphics &mdash; in particular, for drawing icons,
      backgrounds, and windows in which your applications
      work. Without X, you only have command line. X11 sets the screen
      resolution and color depth, moves the mouse cursor around the
      screen, etc. It serves as a foundation for other components of
      graphical user interface such as window managers and desktop
      environments.
    </para>
    <para> <emphasis>Window manager</emphasis> extends capabilities of
      X Window System by placing borders and buttons around windows,
      which allows the user to move, close, hide or resize the
      windows. X11 is virtually always used in combination with a
      window manager, since it would be pretty much unusable without
      one. There are many window managers available for X11; most
      popular are <application>fvwm</application>,
      <application>mwm</application>, <application>kwm</application>
      (used by KDE), <application>Enlightenment</application>, and
      <application>Sawfish</application>.
    </para>
    <para> Finally, a <emphasis>desktop environment</emphasis> goes
      one more step further than a window manager by adding a
      graphical file manager from which you can drag-and-drop items on
      your desktop, a panel which can be used to launch frequently
      used applications, and a set of applications and utilities.
      There are several desktop environments available for all
      versions of UNIX; the most popular ones are <ulink type="http"
      url="http://www.gnome.org">GNOME</ulink>, <ulink type="http"
      url="http://www.kde.org">KDE</ulink> and <ulink type="http"
      url="http://www.sun.com/solaris/cde/">CDE</ulink> (soon to be
      replaced by GNOME).
    </para>
    <para> Most desktop environments contain a window manager as their
      integral part; for example, KDE contains its own window manager,
      <application>kwm</application> (it is possible to use KDE with
      another window manager, but few people do so).  GNOME has no
      window manager of its own; it will allow you to choose any
      window manager you already have on your system. To make life
      easier for new users, usually the
      <application>Sawfish</application> window manager is distributed
      with GNOME and is used by default; you can switch to
      another window manager using <application>GNOME Control
      Center</application>. Note however that you will need a
      GNOME-compliant window manager to use such features of GNOME as 
      session management, taskbar applet, etc. 
    </para>

    </sect1>
	
  
</article>