pwdgroup.xml 4.5 KB

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