[a9e389d] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[bd48e48] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[ed5e88d] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
[a9e389d] | 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
[ed5e88d] | 8 | <sect1 id="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 9 | <?dbhtml filename="creatingfiles.html"?>
|
---|
| 10 |
|
---|
| 11 | <title>Creating the passwd, group, and log Files</title>
|
---|
| 12 |
|
---|
[ed5e88d] | 13 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 14 | <primary sortas="e-/etc/passwd">/etc/passwd</primary>
|
---|
| 15 | </indexterm>
|
---|
| 16 |
|
---|
[ed5e88d] | 17 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 18 | <primary sortas="e-/etc/group">/etc/group</primary>
|
---|
| 19 | </indexterm>
|
---|
| 20 |
|
---|
[ed5e88d] | 21 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 22 | <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
|
---|
| 23 | </indexterm>
|
---|
| 24 |
|
---|
[ed5e88d] | 25 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 26 | <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
|
---|
| 27 | </indexterm>
|
---|
| 28 |
|
---|
[ed5e88d] | 29 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 30 | <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
|
---|
| 31 | </indexterm>
|
---|
| 32 |
|
---|
[ed5e88d] | 33 | <indexterm zone="ch-final-system-creatingfiles">
|
---|
[a9e389d] | 34 | <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
|
---|
| 35 | </indexterm>
|
---|
| 36 |
|
---|
[9b0a535] | 37 | <para>A proper Linux system maintains a list of the mounted file systems in
|
---|
| 38 | the file <filename>/etc/mtab</filename>. With the way our embedded system is
|
---|
| 39 | is designed, we will be using a symlink to <filename>/proc/mounts</filename>:</para>
|
---|
| 40 |
|
---|
[08c1cb1] | 41 | <screen><userinput>ln -svf ../proc/mounts ${CLFS}/targetfs/etc/mtab</userinput></screen>
|
---|
[9b0a535] | 42 |
|
---|
[a9e389d] | 43 | <para>In order for user <systemitem class="username">root</systemitem> to be
|
---|
| 44 | able to login and for the name <quote>root</quote> to be recognized, there
|
---|
| 45 | must be relevant entries in the <filename>/etc/passwd</filename> and
|
---|
| 46 | <filename>/etc/group</filename> files.</para>
|
---|
| 47 |
|
---|
| 48 | <para>Create the <filename>/etc/passwd</filename> file by running the following
|
---|
| 49 | command:</para>
|
---|
| 50 |
|
---|
[08c1cb1] | 51 | <screen><userinput>cat > ${CLFS}/targetfs/etc/passwd << "EOF"
|
---|
[1d67150] | 52 | <literal>root::0:0:root:/root:/bin/ash</literal>
|
---|
[a9e389d] | 53 | EOF</userinput></screen>
|
---|
| 54 |
|
---|
| 55 | <para>The actual password for <systemitem class="username">root</systemitem>
|
---|
| 56 | (the <quote>::</quote> used here is just a placeholder and allow you to login
|
---|
| 57 | with no password) will be set later.</para>
|
---|
| 58 |
|
---|
| 59 | <para>Create the <filename>/etc/group</filename> file by running the following
|
---|
| 60 | command:</para>
|
---|
| 61 |
|
---|
[08c1cb1] | 62 | <screen><userinput>cat > ${CLFS}/targetfs/etc/group << "EOF"
|
---|
[a9e389d] | 63 | <literal>root:x:0:
|
---|
| 64 | bin:x:1:
|
---|
[73c0570] | 65 | users:x:1000:
|
---|
| 66 | nogroup:x:65533:
|
---|
| 67 | nobody:x:65534:</literal>
|
---|
[a9e389d] | 68 | EOF</userinput></screen>
|
---|
| 69 |
|
---|
[73c0570] | 70 | <para>The created groups are not part of any standard. The Linux Standard
|
---|
| 71 | Base (LSB, available at <ulink url="http://www.linuxbase.org"/>) recommends
|
---|
| 72 | only that, besides the group <systemitem class="groupname">root</systemitem>
|
---|
| 73 | with a Group ID (GID) of 0, a group <systemitem
|
---|
| 74 | class="groupname">bin</systemitem> with a GID of 1 be present. All other
|
---|
| 75 | group names and GIDs can be chosen freely by the system administrator since
|
---|
| 76 | well-written programs do not depend on GID numbers, but rather use the
|
---|
| 77 | group's name.</para>
|
---|
[a9e389d] | 78 |
|
---|
| 79 | <para>The <command>login</command>, <command>agetty</command>, and
|
---|
| 80 | <command>init</command> programs (and others) use a number of log
|
---|
| 81 | files to record information such as who was logged into the system and
|
---|
| 82 | when. However, these programs will not write to the log files if they
|
---|
| 83 | do not already exist. Initialize the log files and give them
|
---|
| 84 | proper permissions:</para>
|
---|
| 85 |
|
---|
[08c1cb1] | 86 | <screen><userinput>touch ${CLFS}/targetfs/var/run/utmp ${CLFS}/targetfs/var/log/{btmp,lastlog,wtmp}
|
---|
| 87 | chmod -v 664 ${CLFS}/targetfs/var/run/utmp ${CLFS}/targetfs/var/log/lastlog</userinput></screen>
|
---|
[a9e389d] | 88 |
|
---|
| 89 | <para>The <filename>/var/run/utmp</filename> file records the users
|
---|
| 90 | that are currently logged in. The <filename>/var/log/wtmp</filename>
|
---|
| 91 | file records all logins and logouts. The
|
---|
| 92 | <filename>/var/log/lastlog</filename> file records when
|
---|
| 93 | each user last logged in. The <filename>/var/log/btmp</filename> file
|
---|
| 94 | records the bad login attempts.</para>
|
---|
| 95 |
|
---|
| 96 | </sect1>
|
---|