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