pwdgroup.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. <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 <emphasis>root</emphasis> to be able to login and for the
  16. name <quote>root</quote> to be recognized, there need to be relevant entries in
  17. the <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files.
  18. </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. root:x:0:0:root:/root:/bin/bash
  23. EOF</userinput></screen>
  24. <para>The actual password for <emphasis>root</emphasis> (the <quote>x</quote>
  25. 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. 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:
  44. EOF</userinput></screen>
  45. <para>The created groups aren't part of any standard -- they are some of the
  46. groups that the Udev configuration we will be using in the next section
  47. uses. The LSB (<ulink url="http://www.linuxbase.org/">Linux Standard
  48. Base</ulink>) recommends only that, beside the group <quote>root</quote> with a
  49. GID of 0, a group <quote>bin</quote> with a GID of 1 be present. All other group
  50. names and GIDs can be chosen freely by the system administrator, since
  51. well-written packages don't depend on GID numbers but use the group's name.
  52. </para>
  53. <para>To get rid of the <quote>I have no name!</quote> prompt, we will start a
  54. new shell. Since we installed a full Glibc in
  55. <xref linkend="chapter-temporary-tools"/>, and have just created the
  56. <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files,
  57. user name and group name resolution will now work.</para>
  58. <screen><userinput>exec /tools/bin/bash --login +h</userinput></screen>
  59. <para>Note the use of the <parameter>+h</parameter> directive. This tells
  60. <command>bash</command> not to use its internal path hashing. Without this
  61. directive, <command>bash</command> would remember the paths to binaries it
  62. has executed. Since we want to use our newly compiled binaries as soon as
  63. they are installed, we turn off this function for the duration of this
  64. chapter.</para>
  65. <para>The <command>login</command>, <command>agetty</command> and
  66. <command>init</command> programs (and some others) use a number of log
  67. files to record information such as who was logged into the system and when.
  68. These programs, however, won't write to the log files if they don't already
  69. exist. Initialize the log files and give them their proper permissions:</para>
  70. <screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
  71. chgrp utmp /var/run/utmp /var/log/lastlog
  72. chmod 664 /var/run/utmp /var/log/lastlog</userinput></screen>
  73. <para>The <filename>/var/run/utmp</filename> file records the users that are
  74. currently logged in. The <filename>/var/log/wtmp</filename> file records all
  75. logins and logouts. The <filename>/var/log/lastlog</filename> file records for
  76. each user when he or she last logged in. The <filename>/var/log/btmp</filename>
  77. file records the bad login attempts.</para>
  78. </sect1>