pwdgroup.xml 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/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. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/etc/passwd">/etc/passwd</primary></indexterm>
  10. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/etc/group">/etc/group</primary></indexterm>
  11. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/run/utmp">/var/run/utmp</primary></indexterm>
  12. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/btmp">/var/log/btmp</primary></indexterm>
  13. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary></indexterm>
  14. <indexterm zone="ch-system-pwdgroup"><primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary></indexterm>
  15. <para>In order for user <emphasis>root</emphasis> to be able to login
  16. and for the name <quote>root</quote> to be recognized, there must be relevant
  17. entries in the <filename>/etc/passwd</filename> and
  18. <filename>/etc/group</filename> files.</para>
  19. <para>Create the <filename>/etc/passwd</filename> file by running the following
  20. command:</para>
  21. <screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
  22. <literal>root:x:0:0:root:/root:/bin/bash</literal>
  23. EOF</userinput></screen>
  24. <para>The actual password for <emphasis>root</emphasis> (the <quote>x</quote>
  25. used here is just a placeholder) will be set later.</para>
  26. <para>Create the <filename>/etc/group</filename> file by running the following
  27. command:</para>
  28. <screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
  29. <literal>root:x:0:
  30. bin:x:1:
  31. sys:x:2:
  32. kmem:x:3:
  33. tty:x:4:
  34. tape:x:5:
  35. daemon:x:6:
  36. floppy:x:7:
  37. disk:x:8:
  38. lp:x:9:
  39. dialout:x:10:
  40. audio:x:11:
  41. video:x:12:
  42. utmp:x:13:
  43. usb:x:14:</literal>
  44. EOF</userinput></screen>
  45. <para>The created groups are not part of any standard&mdash;they are groups
  46. decided on in part by the requirements of the Udev configuration in the next
  47. section, and in part by common convention employed by a number of existing Linux
  48. distributions. The Linux Standard Base (LSB, available at <ulink
  49. url="http://www.linuxbase.org"/>) recommends only that, besides the group
  50. <quote>root</quote> with a Group ID (GID) of 0, a group <quote>bin</quote> with
  51. a GID of 1 be present. All other group names and GIDs can be chosen freely by
  52. the system administrator since well-written programs do not depend on GID
  53. numbers, but rather use the group's name.</para>
  54. <para>To remove the <quote>I have no name!</quote> prompt, start a new
  55. shell. Since a full Glibc was installed in <xref
  56. linkend="chapter-temporary-tools"/> and the
  57. <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
  58. files have been created, user name and group name resolution will now
  59. work.</para>
  60. <screen><userinput>exec /tools/bin/bash --login +h</userinput></screen>
  61. <para>Note the use of the <parameter>+h</parameter> directive. This tells
  62. <command>bash</command> not to use its internal path hashing. Without this
  63. directive, <command>bash</command> would remember the paths to binaries it has
  64. executed. To ensure the use of the newly compiled binaries as soon as they are
  65. installed, the <parameter>+h</parameter> directive will be used for the duration
  66. of this chapter.</para>
  67. <para>The <command>login</command>, <command>agetty</command>, and
  68. <command>init</command> programs (and others) use a number of log
  69. files to record information such as who was logged into the system and
  70. when. However, these programs will not write to the log files if they
  71. do not already exist. Initialize the log files and give them
  72. proper permissions:</para>
  73. <screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
  74. chgrp utmp /var/run/utmp /var/log/lastlog
  75. chmod 664 /var/run/utmp /var/log/lastlog</userinput></screen>
  76. <para>The <filename>/var/run/utmp</filename> file records the users
  77. that are currently logged in. The <filename>/var/log/wtmp</filename>
  78. file records all logins and logouts. The
  79. <filename>/var/log/lastlog</filename> file records when
  80. each user last logged in. The <filename>/var/log/btmp</filename> file
  81. records the bad login attempts.</para>
  82. </sect1>