source: chapter07/createfiles.xml@ 5e06d04

multilib-10.1
Last change on this file since 5e06d04 was 5e06d04, checked in by Thomas Trepl <thomas@…>, 3 years ago

Merge changes from trunk to multilib

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@12107 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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