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