source: chapter07/createfiles.xml@ d7a9421

11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since d7a9421 was d7a9421, checked in by Douglas R. Reno <renodr@…>, 3 years ago

Merge Xi's changes into trunk
Update to meson-0.58.0
Update to systemd-248
Update to gcc-11.1.0
Update to linux-5.12.1
Update to iproute2-5.12.0
Update to Python-3.9.5
Make /bin, /sbin, and /lib symlinks to their counterparts in /usr.
Thanks again for a significant portion of this work goes to Xi, I only
really merged it and made a couple of modifications for my updates. To
LFS 11.x we go!

  • Property mode set to 100644
File size: 7.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-createfiles">
9 <?dbhtml filename="createfiles.html"?>
10
11 <title>Creating Essential Files and Symlinks</title>
12
13 <indexterm zone="ch-tools-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-tools-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-tools-createfiles">
22 <primary sortas="e-/run/utmp">/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-tools-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-tools-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-tools-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
36
37 <para>Historically, Linux maintains a list of the mounted file systems in the
38 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
39 internally and exposes it to the user via the <filename
40 class="directory">/proc</filename> filesystem. To satisfy utilities that
41 expect the presence of <filename>/etc/mtab</filename>, create the following
42 symbolic link:</para>
43
44<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
45
46 <para>Create a basic <filename>/etc/hosts</filename> file to be
47 referenced in some test suites, and in one of Perl's configuration files
48 as well:</para>
49
50<screen><userinput>cat &gt; /etc/hosts &lt;&lt; EOF
51"127.0.0.1 localhost $(hostname)"
52::1 localhost
53EOF</userinput></screen>
54
55 <para>In order for user <systemitem class="username">root</systemitem> to be
56 able to login and for the name <quote>root</quote> to be recognized, there
57 must be relevant entries in the <filename>/etc/passwd</filename> and
58 <filename>/etc/group</filename> files.</para>
59
60 <para>Create the <filename>/etc/passwd</filename> file by running the following
61 command:</para>
62
63<screen revision="sysv"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
64<literal>root:x:0:0:root:/root:/bin/bash
65bin:x:1:1:bin:/dev/null:/bin/false
66daemon:x:6:6:Daemon User:/dev/null:/bin/false
67messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/bin/false
68uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false
69nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
70EOF</userinput></screen>
71
72<screen revision="systemd"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
73<literal>root:x:0:0:root:/root:/bin/bash
74bin:x:1:1:bin:/dev/null:/bin/false
75daemon:x:6:6:Daemon User:/dev/null:/bin/false
76messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/bin/false
77systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
78systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
79systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
80systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
81systemd-network:x:76:76:systemd Network Management:/:/bin/false
82systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
83systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
84systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
85uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false
86systemd-oomd:x:81:81:systemd Out Of Memory Daemon:/:/bin/false
87nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
88EOF</userinput></screen>
89
90 <para>The actual password for <systemitem class="username">root</systemitem>
91 will be set later.</para>
92
93 <para>Create the <filename>/etc/group</filename> file by running the following
94 command:</para>
95
96<screen revision="sysv"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
97<literal>root:x:0:
98bin:x:1:daemon
99sys:x:2:
100kmem:x:3:
101tape:x:4:
102tty:x:5:
103daemon:x:6:
104floppy:x:7:
105disk:x:8:
106lp:x:9:
107dialout:x:10:
108audio:x:11:
109video:x:12:
110utmp:x:13:
111usb:x:14:
112cdrom:x:15:
113adm:x:16:
114messagebus:x:18:
115input:x:24:
116mail:x:34:
117kvm:x:61:
118uuidd:x:80:
119wheel:x:97:
120nogroup:x:99:
121users:x:999:</literal>
122EOF</userinput></screen>
123
124<screen revision="systemd"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
125<literal>root:x:0:
126bin:x:1:daemon
127sys:x:2:
128kmem:x:3:
129tape:x:4:
130tty:x:5:
131daemon:x:6:
132floppy:x:7:
133disk:x:8:
134lp:x:9:
135dialout:x:10:
136audio:x:11:
137video:x:12:
138utmp:x:13:
139usb:x:14:
140cdrom:x:15:
141adm:x:16:
142messagebus:x:18:
143systemd-journal:x:23:
144input:x:24:
145mail:x:34:
146kvm:x:61:
147systemd-bus-proxy:x:72:
148systemd-journal-gateway:x:73:
149systemd-journal-remote:x:74:
150systemd-journal-upload:x:75:
151systemd-network:x:76:
152systemd-resolve:x:77:
153systemd-timesync:x:78:
154systemd-coredump:x:79:
155uuidd:x:80:
156systemd-oomd:x:81:81:
157wheel:x:97:
158nogroup:x:99:
159users:x:999:</literal>
160EOF</userinput></screen>
161
162 <para>The created groups are not part of any standard&mdash;they are groups
163 decided on in part by the requirements of the Udev configuration in Chapter
164 9, and in part by common convention employed by a number of existing Linux
165 distributions. In addition, some test suites rely on specific users or
166 groups. The Linux Standard Base (LSB, available at <ulink
167 url="http://refspecs.linuxfoundation.org/lsb.shtml"/>) only recommends that,
168 besides the group <systemitem class="groupname">root</systemitem> with a
169 Group ID (GID) of 0, a group <systemitem class="groupname">bin</systemitem>
170 with a GID of 1 be present. All other group names and GIDs can be chosen
171 freely by the system administrator since well-written programs do not depend
172 on GID numbers, but rather use the group's name.</para>
173
174 <para>Some tests in <xref linkend="chapter-building-system"/> need a regular
175 user. We add this user here and delete this account at the end of that
176 chapter.</para>
177
178<screen><userinput>echo "tester:x:$(ls -n $(tty) | cut -d" " -f3):101::/home/tester:/bin/bash" &gt;&gt; /etc/passwd
179echo "tester:x:101:" &gt;&gt; /etc/group
180install -o tester -d /home/tester</userinput></screen>
181
182 <para>To remove the <quote>I have no name!</quote> prompt, start a new
183 shell. Since the
184 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
185 files have been created, user name and group name resolution will now
186 work:</para>
187
188<screen role="nodump"><userinput>exec /bin/bash --login +h</userinput></screen>
189
190 <para>Note the use of the <parameter>+h</parameter> directive. This tells
191 <command>bash</command> not to use its internal path hashing. Without this
192 directive, <command>bash</command> would remember the paths to binaries it has
193 executed. To ensure the use of the newly compiled binaries as soon as they are
194 installed, the <parameter>+h</parameter> directive will be used for the duration
195 of this and the next chapter.</para>
196
197 <para>The <command>login</command>, <command>agetty</command>, and
198 <command>init</command> programs (and others) use a number of log
199 files to record information such as who was logged into the system and
200 when. However, these programs will not write to the log files if they
201 do not already exist. Initialize the log files and give them
202 proper permissions:</para>
203
204<screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
205chgrp -v utmp /var/log/lastlog
206chmod -v 664 /var/log/lastlog
207chmod -v 600 /var/log/btmp</userinput></screen>
208
209 <para>The <filename>/var/log/wtmp</filename> file records all logins and
210 logouts. The <filename>/var/log/lastlog</filename> file records when each
211 user last logged in. The <filename>/var/log/faillog</filename> file records
212 failed login attempts. The <filename>/var/log/btmp</filename> file records
213 the bad login attempts.</para>
214
215 <note><para>The <filename>/run/utmp</filename> file records the users that
216 are currently logged in. This file is created dynamically in the boot
217 scripts.</para></note>
218
219</sect1>
Note: See TracBrowser for help on using the repository browser.