source: chapter06/createfiles.xml@ 030875a8

10.0 10.0-rc1 10.1 10.1-rc1 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 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 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 030875a8 was 030875a8, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

Update users so all acl tests pass

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10546 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 6.0 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-system-createfiles">
9 <?dbhtml filename="createfiles.html"?>
10
11 <title>Creating Essential Files and Symlinks</title>
12
13 <indexterm zone="ch-system-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-system-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-system-createfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-system-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
36
37 <para>Some programs use hard-wired paths to programs which do not exist yet. In
38 order to satisfy these programs, create a number of symbolic links which will be
39 replaced by real files throughout the course of this chapter after the software
40 has been installed:</para>
41
42<screen><userinput>ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
43ln -sv /tools/bin/perl /usr/bin
44ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
45ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
46sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
47ln -sv bash /bin/sh</userinput></screen>
48
49 <para>Historically, Linux maintains a list of the mounted file systems in the
50 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
51 internally and exposes it to the user via the <filename
52 class="directory">/proc</filename> filesystem. To satisfy utilities that
53 expect the presence of <filename>/etc/mtab</filename>, create the following
54 symbolic link:</para>
55
56<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
57
58 <para>In order for user <systemitem class="username">root</systemitem> to be
59 able to login and for the name <quote>root</quote> to be recognized, there
60 must be relevant entries in the <filename>/etc/passwd</filename> and
61 <filename>/etc/group</filename> files.</para>
62
63 <para>Create the <filename>/etc/passwd</filename> file by running the following
64 command:</para>
65
66<screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
67<literal>root:x:0:0:root:/root:/bin/bash
68bin:x:1:1:bin:/dev/null:/bin/false
69daemon:x:6:6:Daemon User:/dev/null:/bin/false
70messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
71nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
72EOF</userinput></screen>
73
74 <para>The actual password for <systemitem class="username">root</systemitem>
75 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
76
77 <para>Create the <filename>/etc/group</filename> file by running the following
78 command:</para>
79
80<screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
81<literal>root:x:0:
82bin:x:1:daemon
83sys:x:2:
84kmem:x:3:
85tape:x:4:
86tty:x:5:
87daemon:x:6:
88floppy:x:7:
89disk:x:8:
90lp:x:9:
91dialout:x:10:
92audio:x:11:
93video:x:12:
94utmp:x:13:
95usb:x:14:
96cdrom:x:15:
97adm:x:16:
98messagebus:x:18:
99systemd-journal:x:23:
100mail:x:34:
101nogroup:x:99:
102users:x:999:</literal>
103EOF</userinput></screen>
104
105 <para>The created groups are not part of any standard&mdash;they are groups
106 decided on in part by the requirements of the Udev configuration in this
107 chapter, and in part by common convention employed by a number of existing
108 Linux distributions. In addition, some test suites rely on specific users
109 or groups. The Linux Standard Base (LSB, available at <ulink
110 url="http://www.linuxbase.org"/>) recommends only that, besides the group
111 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
112 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
113 present. All other group names and GIDs can be chosen freely by the system
114 administrator since well-written programs do not depend on GID numbers, but
115 rather use the group's name.</para>
116
117 <para>To remove the <quote>I have no name!</quote> prompt, start a new
118 shell. Since a full Glibc was installed in <xref
119 linkend="chapter-temporary-tools"/> and the
120 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
121 files have been created, user name and group name resolution will now
122 work:</para>
123
124<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
125
126 <para>Note the use of the <parameter>+h</parameter> directive. This tells
127 <command>bash</command> not to use its internal path hashing. Without this
128 directive, <command>bash</command> would remember the paths to binaries it has
129 executed. To ensure the use of the newly compiled binaries as soon as they are
130 installed, the <parameter>+h</parameter> directive will be used for the duration
131 of this chapter.</para>
132
133 <para>The <command>login</command>, <command>agetty</command>, and
134 <command>init</command> programs (and others) use a number of log
135 files to record information such as who was logged into the system and
136 when. However, these programs will not write to the log files if they
137 do not already exist. Initialize the log files and give them
138 proper permissions:</para>
139
140<screen><userinput>touch /var/log/{btmp,lastlog,wtmp}
141chgrp -v utmp /var/log/lastlog
142chmod -v 664 /var/log/lastlog
143chmod -v 600 /var/log/btmp</userinput></screen>
144
145 <para>The <filename>/var/log/wtmp</filename> file records all logins and
146 logouts. The <filename>/var/log/lastlog</filename> file records when each
147 user last logged in. The <filename>/var/log/btmp</filename> file records the
148 bad login attempts.</para>
149
150 <note><para>The <filename>/run/utmp</filename> file records the users that
151 are currently logged in. This file is created dynamically in the boot
152 scripts.</para></note>
153
154</sect1>
Note: See TracBrowser for help on using the repository browser.