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