[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 |
|
---|
[8ef8304] | 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
|
---|
[f19e766] | 40 | has been installed:</para>
|
---|
[673b0d8] | 41 |
|
---|
[b943097] | 42 | <screen><userinput>ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
|
---|
[5998892] | 43 | ln -sv /tools/bin/perl /usr/bin
|
---|
| 44 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
---|
[2f94d109] | 45 | ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
|
---|
[e844aee] | 46 | sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
|
---|
[5998892] | 47 | ln -sv bash /bin/sh</userinput></screen>
|
---|
[673b0d8] | 48 |
|
---|
[cc519cf] | 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>
|
---|
[d2c332bc] | 55 |
|
---|
[b1a51ac1] | 56 | <screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
|
---|
[d2c332bc] | 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 > /etc/passwd << "EOF"
|
---|
[4361397] | 67 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
[8f90f47d] | 68 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
[075ac1c] | 69 | daemon:x:6:6:daemon:/dev/null:/bin/false
|
---|
[8edca0a] | 70 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
[390e32c] | 71 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
[d2c332bc] | 72 | EOF</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 > /etc/group << "EOF"
|
---|
| 81 | <literal>root:x:0:
|
---|
| 82 | bin:x:1:
|
---|
| 83 | sys:x:2:
|
---|
| 84 | kmem:x:3:
|
---|
[107e7a5] | 85 | tape:x:4:
|
---|
| 86 | tty:x:5:
|
---|
[d2c332bc] | 87 | daemon:x:6:
|
---|
| 88 | floppy:x:7:
|
---|
| 89 | disk:x:8:
|
---|
| 90 | lp:x:9:
|
---|
[bb8939c] | 91 | dialout:x:10:
|
---|
[d2c332bc] | 92 | audio:x:11:
|
---|
| 93 | video:x:12:
|
---|
| 94 | utmp:x:13:
|
---|
| 95 | usb:x:14:
|
---|
[4361397] | 96 | cdrom:x:15:
|
---|
[0a56911] | 97 | adm:x:16:
|
---|
[8edca0a] | 98 | messagebus:x:18:
|
---|
[cc519cf] | 99 | systemd-journal:x:23:
|
---|
[d1538c0] | 100 | mail:x:34:
|
---|
[4361397] | 101 | nogroup:x:99:</literal>
|
---|
[d2c332bc] | 102 | EOF</userinput></screen>
|
---|
| 103 |
|
---|
| 104 | <para>The created groups are not part of any standard—they are groups
|
---|
| 105 | decided on in part by the requirements of the Udev configuration in this
|
---|
| 106 | chapter, and in part by common convention employed by a number of existing
|
---|
| 107 | Linux distributions. The Linux Standard Base (LSB, available at <ulink
|
---|
| 108 | url="http://www.linuxbase.org"/>) recommends only that, besides the group
|
---|
| 109 | <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
|
---|
| 110 | a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
|
---|
| 111 | present. All other group names and GIDs can be chosen freely by the system
|
---|
| 112 | administrator since well-written programs do not depend on GID numbers, but
|
---|
| 113 | rather use the group's name.</para>
|
---|
| 114 |
|
---|
| 115 | <para>To remove the <quote>I have no name!</quote> prompt, start a new
|
---|
| 116 | shell. Since a full Glibc was installed in <xref
|
---|
| 117 | linkend="chapter-temporary-tools"/> and the
|
---|
| 118 | <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
|
---|
| 119 | files have been created, user name and group name resolution will now
|
---|
[f19e766] | 120 | work:</para>
|
---|
[d2c332bc] | 121 |
|
---|
| 122 | <screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
|
---|
| 123 |
|
---|
| 124 | <para>Note the use of the <parameter>+h</parameter> directive. This tells
|
---|
| 125 | <command>bash</command> not to use its internal path hashing. Without this
|
---|
| 126 | directive, <command>bash</command> would remember the paths to binaries it has
|
---|
| 127 | executed. To ensure the use of the newly compiled binaries as soon as they are
|
---|
| 128 | installed, the <parameter>+h</parameter> directive will be used for the duration
|
---|
| 129 | of this chapter.</para>
|
---|
| 130 |
|
---|
| 131 | <para>The <command>login</command>, <command>agetty</command>, and
|
---|
| 132 | <command>init</command> programs (and others) use a number of log
|
---|
| 133 | files to record information such as who was logged into the system and
|
---|
| 134 | when. However, these programs will not write to the log files if they
|
---|
| 135 | do not already exist. Initialize the log files and give them
|
---|
| 136 | proper permissions:</para>
|
---|
| 137 |
|
---|
[44f6add] | 138 | <screen><userinput>touch /var/log/{btmp,lastlog,wtmp}
|
---|
[4f2e707] | 139 | chgrp -v utmp /var/log/lastlog
|
---|
| 140 | chmod -v 664 /var/log/lastlog
|
---|
| 141 | chmod -v 600 /var/log/btmp</userinput></screen>
|
---|
[d2c332bc] | 142 |
|
---|
[44f6add] | 143 | <para>The <filename>/var/log/wtmp</filename> file records all logins and
|
---|
| 144 | logouts. The <filename>/var/log/lastlog</filename> file records when each
|
---|
| 145 | user last logged in. The <filename>/var/log/btmp</filename> file records the
|
---|
| 146 | bad login attempts.</para>
|
---|
| 147 |
|
---|
| 148 | <note><para>The <filename>/run/utmp</filename> file records the users that
|
---|
| 149 | are currently logged in. This file is created dynamically in the boot
|
---|
| 150 | scripts.</para></note>
|
---|
[d2c332bc] | 151 |
|
---|
[673b0d8] | 152 | </sect1>
|
---|