1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
4 | %general-entities;
|
---|
5 | ]>
|
---|
6 | <sect1 id="ch-system-pwdgroup">
|
---|
7 | <title>Creating the passwd, group and log files</title>
|
---|
8 | <?dbhtml filename="pwdgroup.html"?>
|
---|
9 |
|
---|
10 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/etc/passwd">/etc/passwd</primary></indexterm>
|
---|
11 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/etc/group">/etc/group</primary></indexterm>
|
---|
12 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/run/utmp">/var/run/utmp</primary></indexterm>
|
---|
13 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/btmp">/var/log/btmp</primary></indexterm>
|
---|
14 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary></indexterm>
|
---|
15 | <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary></indexterm>
|
---|
16 |
|
---|
17 | <para>In order for <emphasis>root</emphasis> to be able to login and for the
|
---|
18 | name <quote>root</quote> to be recognized, there need to be relevant entries in
|
---|
19 | the <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files.
|
---|
20 | </para>
|
---|
21 |
|
---|
22 | <para>Create the <filename>/etc/passwd</filename> file by running the following
|
---|
23 | command:</para>
|
---|
24 |
|
---|
25 | <screen><userinput>cat > /etc/passwd << "EOF"</userinput>
|
---|
26 | root:x:0:0:root:/root:/bin/bash
|
---|
27 | <userinput>EOF</userinput></screen>
|
---|
28 |
|
---|
29 | <para>The actual password for <emphasis>root</emphasis> (the <quote>x</quote>
|
---|
30 | here is just a placeholder) will be set later.</para>
|
---|
31 |
|
---|
32 | <para>Create the <filename>/etc/group</filename> file by running the following
|
---|
33 | command:</para>
|
---|
34 |
|
---|
35 | <screen><userinput>cat > /etc/group << "EOF"</userinput>
|
---|
36 | root:x:0:
|
---|
37 | bin:x:1:
|
---|
38 | sys:x:2:
|
---|
39 | kmem:x:3:
|
---|
40 | tty:x:4:
|
---|
41 | tape:x:5:
|
---|
42 | daemon:x:6:
|
---|
43 | floppy:x:7:
|
---|
44 | disk:x:8:
|
---|
45 | lp:x:9:
|
---|
46 | dialout:x:10:
|
---|
47 | audio:x:11:
|
---|
48 | <userinput>EOF</userinput></screen>
|
---|
49 |
|
---|
50 | <para>The created groups aren't part of any standard -- they are some of the
|
---|
51 | groups that the <command>make_devices</command> script in the next section
|
---|
52 | uses. The LSB (<ulink url="http://www.linuxbase.org/">Linux Standard
|
---|
53 | Base</ulink>) recommends only that, beside the group <quote>root</quote> with a
|
---|
54 | GID of 0, a group <quote>bin</quote> with a GID of 1 be present. All other group
|
---|
55 | names and GIDs can be chosen freely by the system administrator, since
|
---|
56 | well-written packages don't depend on GID numbers but use the group's name.
|
---|
57 | </para>
|
---|
58 |
|
---|
59 | <para>To get rid of the <quote>I have no name!</quote> prompt, we will start a
|
---|
60 | new shell. Since we installed a full Glibc in
|
---|
61 | <xref linkend="chapter-temporary-tools"/>, and have just created the
|
---|
62 | <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files,
|
---|
63 | user name and group name resolution will now work.</para>
|
---|
64 |
|
---|
65 | <screen><userinput>exec /tools/bin/bash --login +h</userinput></screen>
|
---|
66 |
|
---|
67 | <para>Note the use of the <emphasis>+h</emphasis> directive. This tells
|
---|
68 | <command>bash</command> not to use its internal path hashing. Without this
|
---|
69 | directive, <command>bash</command> would remember the paths to binaries it
|
---|
70 | has executed. Since we want to use our newly compiled binaries as soon as
|
---|
71 | they are installed, we turn off this function for the duration of this
|
---|
72 | chapter.</para>
|
---|
73 |
|
---|
74 | <para>The <command>login</command>, <command>agetty</command> and
|
---|
75 | <command>init</command> programs (and some others) use a number of log
|
---|
76 | files to record information such as who was logged into the system and when.
|
---|
77 | These programs, however, won't write to the log files if they don't already
|
---|
78 | exist. Initialize the log files and give them their proper permissions:</para>
|
---|
79 |
|
---|
80 | <screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
|
---|
81 | chmod 644 /var/run/utmp /var/log/{btmp,lastlog,wtmp}</userinput></screen>
|
---|
82 |
|
---|
83 | <para>The <filename>/var/run/utmp</filename> file records the users that are
|
---|
84 | currently logged in. The <filename>/var/log/wtmp</filename> file records all
|
---|
85 | logins and logouts. The <filename>/var/log/lastlog</filename> file records for
|
---|
86 | each user when he or she last logged in. The <filename>/var/log/btmp</filename>
|
---|
87 | file records the bad login attempts.</para>
|
---|
88 |
|
---|
89 | </sect1>
|
---|