[02095ae] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-final-preps-creatingfiles">
|
---|
| 9 | <?dbhtml filename="creatingfiles.html"?>
|
---|
| 10 |
|
---|
[3349a3a] | 11 | <title>Creating the passwd, group, and log Files</title>
|
---|
| 12 |
|
---|
| 13 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 14 | <primary sortas="e-/etc/passwd">/etc/passwd</primary>
|
---|
| 15 | </indexterm>
|
---|
| 16 |
|
---|
| 17 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 18 | <primary sortas="e-/etc/group">/etc/group</primary>
|
---|
| 19 | </indexterm>
|
---|
| 20 |
|
---|
| 21 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 22 | <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
|
---|
| 23 | </indexterm>
|
---|
| 24 |
|
---|
| 25 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 26 | <primary sortas="e-${LFS}/var/log/btmp">/var/log/btmp</primary>
|
---|
| 27 | </indexterm>
|
---|
| 28 |
|
---|
| 29 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 30 | <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
|
---|
| 31 | </indexterm>
|
---|
| 32 |
|
---|
| 33 | <indexterm zone="ch-final-preps-creatingfiles">
|
---|
| 34 | <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
|
---|
| 35 | </indexterm>
|
---|
[02095ae] | 36 |
|
---|
| 37 | <para>A proper Linux system maintains a list of the mounted file systems in
|
---|
| 38 | the file <filename>/etc/mtab</filename>. Normally, this file would be
|
---|
| 39 | created when we mount a new file system. Since we will not be mounting any
|
---|
| 40 | file systems inside our chroot environment, create an empty file for
|
---|
| 41 | utilities that expect the presence of <filename>/etc/mtab</filename>:</para>
|
---|
| 42 |
|
---|
| 43 | <screen><userinput>touch ${LFS}/etc/mtab</userinput></screen>
|
---|
| 44 |
|
---|
| 45 | <para>In order for user <systemitem class="username">root</systemitem> to be
|
---|
| 46 | able to login and for the name <quote>root</quote> to be recognized, there
|
---|
| 47 | must be relevant entries in the <filename>/etc/passwd</filename> and
|
---|
| 48 | <filename>/etc/group</filename> files.</para>
|
---|
| 49 |
|
---|
| 50 | <para>Create the <filename>/etc/passwd</filename> file by running the following
|
---|
| 51 | command:</para>
|
---|
| 52 |
|
---|
[1f0a9c9] | 53 | <screen><userinput>cat > ${LFS}/etc/passwd << "EOF"
|
---|
[02095ae] | 54 | <literal>root:x:0:0:root:/root:/bin/bash</literal>
|
---|
| 55 | EOF</userinput></screen>
|
---|
| 56 |
|
---|
| 57 | <para>The actual password for <systemitem class="username">root</systemitem>
|
---|
| 58 | (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
|
---|
| 59 |
|
---|
| 60 | <para>Create the <filename>/etc/group</filename> file by running the following
|
---|
| 61 | command:</para>
|
---|
| 62 |
|
---|
| 63 | <screen><userinput>cat > ${LFS}/etc/group << "EOF"
|
---|
| 64 | <literal>root:x:0:
|
---|
| 65 | bin:x:1:
|
---|
| 66 | sys:x:2:
|
---|
| 67 | kmem:x:3:
|
---|
| 68 | tty:x:4:
|
---|
| 69 | tape:x:5:
|
---|
| 70 | daemon:x:6:
|
---|
| 71 | floppy:x:7:
|
---|
| 72 | disk:x:8:
|
---|
| 73 | lp:x:9:
|
---|
| 74 | dialout:x:10:
|
---|
| 75 | audio:x:11:
|
---|
| 76 | video:x:12:
|
---|
| 77 | utmp:x:13:
|
---|
| 78 | usb:x:14:
|
---|
| 79 | cdrom:x:15:</literal>
|
---|
| 80 | EOF</userinput></screen>
|
---|
| 81 |
|
---|
| 82 | <para>The created groups are not part of any standard—they are groups
|
---|
| 83 | decided on in part by the requirements of the Udev configuration in this
|
---|
| 84 | chapter, and in part by common convention employed by a number of existing
|
---|
| 85 | Linux distributions. The Linux Standard Base (LSB, available at <ulink
|
---|
| 86 | url="http://www.linuxbase.org"/>) recommends only that, besides the group
|
---|
| 87 | <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
|
---|
| 88 | a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
|
---|
| 89 | present. All other group names and GIDs can be chosen freely by the system
|
---|
| 90 | administrator since well-written programs do not depend on GID numbers, but
|
---|
| 91 | rather use the group's name.</para>
|
---|
| 92 |
|
---|
| 93 | <para>The <command>login</command>, <command>agetty</command>, and
|
---|
| 94 | <command>init</command> programs (and others) use a number of log
|
---|
| 95 | files to record information such as who was logged into the system and
|
---|
| 96 | when. However, these programs will not write to the log files if they
|
---|
| 97 | do not already exist. Initialize the log files and give them
|
---|
| 98 | proper permissions:</para>
|
---|
| 99 |
|
---|
| 100 | <screen><userinput>touch ${LFS}/var/run/utmp ${LFS}/var/log/{btmp,lastlog,wtmp}
|
---|
| 101 | chmod -v 664 ${LFS}/var/run/utmp ${LFS}/var/log/lastlog</userinput></screen>
|
---|
| 102 |
|
---|
| 103 | <para>The <filename>/var/run/utmp</filename> file records the users
|
---|
| 104 | that are currently logged in. The <filename>/var/log/wtmp</filename>
|
---|
| 105 | file records all logins and logouts. The
|
---|
| 106 | <filename>/var/log/lastlog</filename> file records when
|
---|
| 107 | each user last logged in. The <filename>/var/log/btmp</filename> file
|
---|
| 108 | records the bad login attempts.</para>
|
---|
| 109 |
|
---|
| 110 | </sect1>
|
---|