[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[8ef8304] | 7 |
|
---|
[673b0d8] | 8 | <sect1 id="ch-system-createfiles">
|
---|
[8ef8304] | 9 | <?dbhtml filename="createfiles.html"?>
|
---|
| 10 |
|
---|
[d2c332bc] | 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>
|
---|
[673b0d8] | 36 |
|
---|
[d1a862d7] | 37 | <para>Some programs use hard-wired paths to programs which do not exist yet.
|
---|
| 38 | In order to satisfy these programs, create a number of symbolic links which
|
---|
| 39 | will be replaced by real files throughout the course of this chapter after the
|
---|
| 40 | software has been installed:</para>
|
---|
[673b0d8] | 41 |
|
---|
[d1a862d7] | 42 | <screen revision="sysv"><userinput>ln -sv /tools/bin/{bash,cat,dd,echo,ln,pwd,rm,stty} /bin
|
---|
| 43 | ln -sv /tools/bin/{install,perl} /usr/bin
|
---|
[5998892] | 44 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
---|
[5fa3da5] | 45 | ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
|
---|
[e844aee] | 46 | sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
|
---|
[d1a862d7] | 47 | ln -sv bash /bin/sh</userinput></screen>
|
---|
| 48 |
|
---|
| 49 | <screen revision="systemd"><userinput>ln -sv /tools/bin/{bash,cat,dd,echo,ln,pwd,rm,stty} /bin
|
---|
| 50 | ln -sv /tools/bin/{install,perl} /usr/bin
|
---|
| 51 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
---|
| 52 | ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
|
---|
| 53 | sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
|
---|
| 54 | for lib in blkid lzma mount uuid
|
---|
| 55 | do
|
---|
| 56 | ln -sv /tools/lib/lib$lib.{a,so*} /usr/lib
|
---|
| 57 | sed 's/tools/usr/' /tools/lib/lib${lib}.la > /usr/lib/lib${lib}.la
|
---|
| 58 | done
|
---|
[5998892] | 59 | ln -sv bash /bin/sh</userinput></screen>
|
---|
[673b0d8] | 60 |
|
---|
[448e226] | 61 | <variablelist>
|
---|
| 62 | <title>The purpose of each link:</title>
|
---|
| 63 |
|
---|
| 64 | <varlistentry>
|
---|
| 65 | <term><parameter><filename>/bin/bash</filename></parameter></term>
|
---|
| 66 | <listitem>
|
---|
| 67 | <para>Many <command>bash</command> scripts specify
|
---|
| 68 | <filename>/bin/bash</filename>.</para>
|
---|
| 69 | </listitem>
|
---|
| 70 | </varlistentry>
|
---|
| 71 |
|
---|
| 72 | <varlistentry>
|
---|
| 73 | <term><parameter><filename>/bin/cat</filename></parameter></term>
|
---|
| 74 | <listitem>
|
---|
| 75 | <para>This pathname is hard-coded into Glibc's configure script.</para>
|
---|
| 76 | </listitem>
|
---|
| 77 | </varlistentry>
|
---|
| 78 |
|
---|
[d1a862d7] | 79 | <varlistentry>
|
---|
| 80 | <term><parameter><filename>/bin/dd</filename></parameter></term>
|
---|
| 81 | <listitem>
|
---|
| 82 | <para>The path to <filename>dd</filename> will be hard-coded into the
|
---|
| 83 | <filename>/usr/bin/libtool</filename> utility.</para>
|
---|
| 84 | </listitem>
|
---|
| 85 | </varlistentry>
|
---|
| 86 |
|
---|
[448e226] | 87 | <varlistentry>
|
---|
| 88 | <term><parameter><filename>/bin/echo</filename></parameter></term>
|
---|
| 89 | <listitem>
|
---|
| 90 | <para>This is to satisfy one of the tests in Glibc's test suite, which
|
---|
| 91 | expects <filename>/bin/echo</filename>.</para>
|
---|
| 92 | </listitem>
|
---|
| 93 | </varlistentry>
|
---|
| 94 |
|
---|
[d1a862d7] | 95 | <varlistentry>
|
---|
| 96 | <term><parameter><filename>/usr/bin/install</filename></parameter></term>
|
---|
| 97 | <listitem>
|
---|
| 98 | <para>The path to <filename>install</filename> will be hard-coded into
|
---|
| 99 | the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>
|
---|
| 100 | </listitem>
|
---|
| 101 | </varlistentry>
|
---|
| 102 |
|
---|
| 103 | <varlistentry>
|
---|
| 104 | <term><parameter><filename>/bin/ln</filename></parameter></term>
|
---|
| 105 | <listitem>
|
---|
| 106 | <para>The path to <filename>ln</filename> will be hard-coded into the
|
---|
| 107 | <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>
|
---|
| 108 | file.</para>
|
---|
| 109 | </listitem>
|
---|
| 110 | </varlistentry>
|
---|
| 111 |
|
---|
[448e226] | 112 | <varlistentry>
|
---|
| 113 | <term><parameter><filename>/bin/pwd</filename></parameter></term>
|
---|
| 114 | <listitem>
|
---|
| 115 | <para>Some <command>configure</command> scripts, particularly Glibc's,
|
---|
| 116 | have this pathname hard-coded.</para>
|
---|
| 117 | </listitem>
|
---|
| 118 | </varlistentry>
|
---|
| 119 |
|
---|
[d1a862d7] | 120 | <varlistentry>
|
---|
| 121 | <term><parameter><filename>/bin/rm</filename></parameter></term>
|
---|
| 122 | <listitem>
|
---|
| 123 | <para>The path to <filename>rm</filename> will be hard-coded into the
|
---|
| 124 | <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>
|
---|
| 125 | file.</para>
|
---|
| 126 | </listitem>
|
---|
| 127 | </varlistentry>
|
---|
| 128 |
|
---|
[448e226] | 129 | <varlistentry>
|
---|
| 130 | <term><parameter><filename>/bin/stty</filename></parameter></term>
|
---|
| 131 | <listitem>
|
---|
| 132 | <para>This pathname is hard-coded into Expect, therefore it is needed
|
---|
| 133 | for Binutils and GCC test suites to pass.</para>
|
---|
| 134 | </listitem>
|
---|
| 135 | </varlistentry>
|
---|
| 136 |
|
---|
| 137 | <varlistentry>
|
---|
| 138 | <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
|
---|
| 139 | <listitem>
|
---|
| 140 | <para>Many Perl scripts hard-code this path to the
|
---|
| 141 | <command>perl</command> program.</para>
|
---|
| 142 | </listitem>
|
---|
| 143 | </varlistentry>
|
---|
| 144 |
|
---|
| 145 | <varlistentry>
|
---|
| 146 | <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
|
---|
| 147 | <listitem>
|
---|
| 148 | <para>Glibc needs this for the pthreads library to work.</para>
|
---|
| 149 | </listitem>
|
---|
| 150 | </varlistentry>
|
---|
| 151 |
|
---|
| 152 | <varlistentry>
|
---|
| 153 | <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
|
---|
| 154 | <listitem>
|
---|
| 155 | <para>This is needed by several tests in Glibc's test suite, as well as
|
---|
| 156 | for C++ support in GMP.</para>
|
---|
| 157 | </listitem>
|
---|
| 158 | </varlistentry>
|
---|
| 159 |
|
---|
| 160 | <varlistentry>
|
---|
| 161 | <term><parameter><filename>/usr/lib/libstdc++.la</filename></parameter></term>
|
---|
| 162 | <listitem>
|
---|
| 163 | <para>This prevents a <filename class="directory">/tools</filename>
|
---|
| 164 | reference that would otherwise be in
|
---|
| 165 | <filename>/usr/lib/libstdc++.la</filename> after GCC is installed.</para>
|
---|
| 166 | </listitem>
|
---|
| 167 | </varlistentry>
|
---|
| 168 |
|
---|
[d1a862d7] | 169 | <varlistentry revision="systemd">
|
---|
| 170 | <term><parameter><filename>/usr/lib/lib{blkid,lzma,mount,uuid}.{a,la,so*}</filename></parameter></term>
|
---|
| 171 | <listitem>
|
---|
[26a1b33] | 172 | <para>These links prevent systemd utilities from acquiring an
|
---|
[d1a862d7] | 173 | unnecessary reference to the
|
---|
| 174 | <filename class="directory">/tools</filename> directory.</para>
|
---|
| 175 | </listitem>
|
---|
| 176 | </varlistentry>
|
---|
| 177 |
|
---|
[448e226] | 178 | <varlistentry>
|
---|
| 179 | <term><parameter><filename>/bin/sh</filename></parameter></term>
|
---|
| 180 | <listitem>
|
---|
| 181 | <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
|
---|
| 182 | </listitem>
|
---|
| 183 | </varlistentry>
|
---|
| 184 |
|
---|
| 185 | </variablelist>
|
---|
| 186 |
|
---|
[85e7f3c] | 187 | <para>Historically, Linux maintains a list of the mounted file systems in the
|
---|
[ba8848f] | 188 | file <filename>/etc/mtab</filename>. Modern kernels maintain this list
|
---|
[85e7f3c] | 189 | internally and exposes it to the user via the <filename
|
---|
[ba8848f] | 190 | class="directory">/proc</filename> filesystem. To satisfy utilities that
|
---|
[85e7f3c] | 191 | expect the presence of <filename>/etc/mtab</filename>, create the following
|
---|
| 192 | symbolic link:</para>
|
---|
| 193 |
|
---|
| 194 | <screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
|
---|
[d2c332bc] | 195 |
|
---|
| 196 | <para>In order for user <systemitem class="username">root</systemitem> to be
|
---|
| 197 | able to login and for the name <quote>root</quote> to be recognized, there
|
---|
| 198 | must be relevant entries in the <filename>/etc/passwd</filename> and
|
---|
| 199 | <filename>/etc/group</filename> files.</para>
|
---|
| 200 |
|
---|
| 201 | <para>Create the <filename>/etc/passwd</filename> file by running the following
|
---|
| 202 | command:</para>
|
---|
| 203 |
|
---|
[1118b17] | 204 | <screen revision="sysv"><userinput>cat > /etc/passwd << "EOF"
|
---|
[4361397] | 205 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
[8f90f47d] | 206 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
[030875a8] | 207 | daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
---|
[f8fe8970] | 208 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
[390e32c] | 209 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
[1118b17] | 210 | EOF</userinput></screen>
|
---|
| 211 |
|
---|
[cbd8bf0f] | 212 | <screen revision="systemd"><userinput>cat > /etc/passwd << "EOF"
|
---|
[1118b17] | 213 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
| 214 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
| 215 | daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
---|
| 216 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
| 217 | systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
|
---|
| 218 | systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
|
---|
| 219 | systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
|
---|
| 220 | systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
|
---|
| 221 | systemd-network:x:76:76:systemd Network Management:/:/bin/false
|
---|
| 222 | systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
|
---|
| 223 | systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
|
---|
| 224 | systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
|
---|
| 225 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
[d2c332bc] | 226 | EOF</userinput></screen>
|
---|
| 227 |
|
---|
| 228 | <para>The actual password for <systemitem class="username">root</systemitem>
|
---|
| 229 | (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
|
---|
| 230 |
|
---|
| 231 | <para>Create the <filename>/etc/group</filename> file by running the following
|
---|
| 232 | command:</para>
|
---|
| 233 |
|
---|
[1118b17] | 234 | <screen revision="sysv"><userinput>cat > /etc/group << "EOF"
|
---|
| 235 | <literal>root:x:0:
|
---|
| 236 | bin:x:1:daemon
|
---|
| 237 | sys:x:2:
|
---|
| 238 | kmem:x:3:
|
---|
| 239 | tape:x:4:
|
---|
| 240 | tty:x:5:
|
---|
| 241 | daemon:x:6:
|
---|
| 242 | floppy:x:7:
|
---|
| 243 | disk:x:8:
|
---|
| 244 | lp:x:9:
|
---|
| 245 | dialout:x:10:
|
---|
| 246 | audio:x:11:
|
---|
| 247 | video:x:12:
|
---|
| 248 | utmp:x:13:
|
---|
| 249 | usb:x:14:
|
---|
| 250 | cdrom:x:15:
|
---|
| 251 | adm:x:16:
|
---|
| 252 | messagebus:x:18:
|
---|
| 253 | systemd-journal:x:23:
|
---|
| 254 | input:x:24:
|
---|
| 255 | mail:x:34:
|
---|
| 256 | nogroup:x:99:
|
---|
| 257 | users:x:999:</literal>
|
---|
| 258 | EOF</userinput></screen>
|
---|
| 259 |
|
---|
| 260 | <screen revision="systemd"><userinput>cat > /etc/group << "EOF"
|
---|
[d2c332bc] | 261 | <literal>root:x:0:
|
---|
[030875a8] | 262 | bin:x:1:daemon
|
---|
[d2c332bc] | 263 | sys:x:2:
|
---|
| 264 | kmem:x:3:
|
---|
[107e7a5] | 265 | tape:x:4:
|
---|
| 266 | tty:x:5:
|
---|
[d2c332bc] | 267 | daemon:x:6:
|
---|
| 268 | floppy:x:7:
|
---|
| 269 | disk:x:8:
|
---|
| 270 | lp:x:9:
|
---|
[bb8939c] | 271 | dialout:x:10:
|
---|
[d2c332bc] | 272 | audio:x:11:
|
---|
| 273 | video:x:12:
|
---|
| 274 | utmp:x:13:
|
---|
| 275 | usb:x:14:
|
---|
[4361397] | 276 | cdrom:x:15:
|
---|
[f8fe8970] | 277 | adm:x:16:
|
---|
| 278 | messagebus:x:18:
|
---|
| 279 | systemd-journal:x:23:
|
---|
[e4429b7] | 280 | input:x:24:
|
---|
[d1538c0] | 281 | mail:x:34:
|
---|
[1118b17] | 282 | systemd-bus-proxy:x:72:
|
---|
| 283 | systemd-journal-gateway:x:73:
|
---|
| 284 | systemd-journal-remote:x:74:
|
---|
| 285 | systemd-journal-upload:x:75:
|
---|
| 286 | systemd-network:x:76:
|
---|
| 287 | systemd-resolve:x:77:
|
---|
| 288 | systemd-timesync:x:78:
|
---|
| 289 | systemd-coredump:x:79:
|
---|
[030875a8] | 290 | nogroup:x:99:
|
---|
| 291 | users:x:999:</literal>
|
---|
[d2c332bc] | 292 | EOF</userinput></screen>
|
---|
| 293 |
|
---|
| 294 | <para>The created groups are not part of any standard—they are groups
|
---|
| 295 | decided on in part by the requirements of the Udev configuration in this
|
---|
| 296 | chapter, and in part by common convention employed by a number of existing
|
---|
[030875a8] | 297 | Linux distributions. In addition, some test suites rely on specific users
|
---|
| 298 | or groups. The Linux Standard Base (LSB, available at <ulink
|
---|
[d2c332bc] | 299 | url="http://www.linuxbase.org"/>) recommends only that, besides the group
|
---|
| 300 | <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
|
---|
| 301 | a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
|
---|
| 302 | present. All other group names and GIDs can be chosen freely by the system
|
---|
| 303 | administrator since well-written programs do not depend on GID numbers, but
|
---|
| 304 | rather use the group's name.</para>
|
---|
| 305 |
|
---|
| 306 | <para>To remove the <quote>I have no name!</quote> prompt, start a new
|
---|
| 307 | shell. Since a full Glibc was installed in <xref
|
---|
| 308 | linkend="chapter-temporary-tools"/> and the
|
---|
| 309 | <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
|
---|
| 310 | files have been created, user name and group name resolution will now
|
---|
[f19e766] | 311 | work:</para>
|
---|
[d2c332bc] | 312 |
|
---|
| 313 | <screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
|
---|
| 314 |
|
---|
| 315 | <para>Note the use of the <parameter>+h</parameter> directive. This tells
|
---|
| 316 | <command>bash</command> not to use its internal path hashing. Without this
|
---|
| 317 | directive, <command>bash</command> would remember the paths to binaries it has
|
---|
| 318 | executed. To ensure the use of the newly compiled binaries as soon as they are
|
---|
| 319 | installed, the <parameter>+h</parameter> directive will be used for the duration
|
---|
| 320 | of this chapter.</para>
|
---|
| 321 |
|
---|
| 322 | <para>The <command>login</command>, <command>agetty</command>, and
|
---|
| 323 | <command>init</command> programs (and others) use a number of log
|
---|
| 324 | files to record information such as who was logged into the system and
|
---|
| 325 | when. However, these programs will not write to the log files if they
|
---|
| 326 | do not already exist. Initialize the log files and give them
|
---|
| 327 | proper permissions:</para>
|
---|
| 328 |
|
---|
[5bf238b] | 329 | <screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
|
---|
[4f2e707] | 330 | chgrp -v utmp /var/log/lastlog
|
---|
| 331 | chmod -v 664 /var/log/lastlog
|
---|
| 332 | chmod -v 600 /var/log/btmp</userinput></screen>
|
---|
[d2c332bc] | 333 |
|
---|
[44f6add] | 334 | <para>The <filename>/var/log/wtmp</filename> file records all logins and
|
---|
| 335 | logouts. The <filename>/var/log/lastlog</filename> file records when each
|
---|
[5bf238b] | 336 | user last logged in. The <filename>/var/log/faillog</filename> file records
|
---|
| 337 | failed login attempts. The <filename>/var/log/btmp</filename> file records
|
---|
| 338 | the bad login attempts.</para>
|
---|
[44f6add] | 339 |
|
---|
| 340 | <note><para>The <filename>/run/utmp</filename> file records the users that
|
---|
| 341 | are currently logged in. This file is created dynamically in the boot
|
---|
| 342 | scripts.</para></note>
|
---|
[d2c332bc] | 343 |
|
---|
[673b0d8] | 344 | </sect1>
|
---|