Subversion Repositories svn LFS-FR

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
 <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-final-preps-creatingfiles">
  <?dbhtml filename="creatingfiles.html"?>

  <title>Creating the passwd, group, and log Files</title>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/etc/passwd">/etc/passwd</primary>
  </indexterm>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/etc/group">/etc/group</primary>
  </indexterm>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
  </indexterm>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
  </indexterm>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
  </indexterm>

  <indexterm zone="ch-final-preps-creatingfiles">
    <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
  </indexterm>

  <para>In order for user <systemitem class="username">root</systemitem> to be
  able to login and for the name <quote>root</quote> to be recognized, there
  must be relevant entries in the <filename>/etc/passwd</filename> and
  <filename>/etc/group</filename> files.</para>

  <para>Create the <filename>/etc/passwd</filename> file by running the following
  command:</para>

<screen><userinput>cat &gt; ${CLFS}/etc/passwd &lt;&lt; "EOF"
<literal>root::&uid-root;:&gid-root;:root:/root:/bin/bash</literal>
EOF</userinput></screen>

  <para>The actual password for <systemitem class="username">root</systemitem>
  (the <quote>::</quote> used here is just a placeholder and allow you to login
  with no password) will be set later.</para>

  <variablelist os="b">

    <title>Additional users you may want to add:</title>

    <varlistentry>
      <term><literal>bin:x:&uid-bin;:&gid-bin;:bin:/bin:/bin/false</literal></term>
      <listitem>
        <para>Can be useful for compatibility with legacy applications.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>daemon:x:&uid-daemon;:&uid-daemon;:daemon:/sbin:/bin/false</literal></term>
      <listitem>
        <para>It is often recommended to use an unprivileged User ID/Group ID
        for daemons in order to limit their access to the system.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>adm:x:&uid-adm;:&gid-adm;:adm:/var/adm:/bin/false</literal></term>
      <listitem>
        <para>Was used for programs that performed administrative tasks.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>lp:x:&uid-lp;:&gid-lp;:lp:/var/spool/lp:/bin/false</literal></term>
      <listitem>
        <para>Used by programs for printing.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>mail:x:&uid-mail;:&gid-mail;:mail:/var/mail:/bin/false</literal></term>
      <listitem>
        <para>Often used by email programs.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>news:x:&uid-news;:&gid-news;:news:/var/spool/news:/bin/false</literal></term>
      <listitem>
        <para>Often used for network news servers.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>operator:x:&uid-operator;:&gid-root;:operator:/root:/bin/bash</literal></term>
      <listitem>
        <para>Often used to allow system operators to access the system.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>postmaster:x:&uid-postmaster;:&gid-mail;:postmaster:/var/spool/mail:/bin/false</literal></term>
      <listitem>
        <para>Generally used as an account that receives all the information of troubles with the mail server.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>nobody:x:&uid-nobody;:&gid-nobody;:nobody:/:/bin/false</literal></term>
      <listitem>
        <para>Used by NFS.</para>
      </listitem>
    </varlistentry>
  </variablelist>

  <para>Create the <filename>/etc/group</filename> file by running the following
  command:</para>

<screen><userinput>cat &gt; ${CLFS}/etc/group &lt;&lt; "EOF"
<literal>root:x:&gid-root;:
bin:x:&gid-bin;:
sys:x:&gid-sys;:
kmem:x:&gid-kmem;:
tty:x:&gid-tty;:
tape:x:&gid-tape;:
daemon:x:&gid-daemon;:
floppy:x:&gid-floppy;:
disk:x:&gid-disk;:
lp:x:&gid-lp;:
dialout:x:&gid-dialout;:
audio:x:&gid-audio;:
video:x:&gid-video;:
utmp:x:&gid-utmp;:
usb:x:&gid-usb;:
cdrom:x:&gid-cdrom;:</literal>
EOF</userinput></screen>

  <variablelist os="c">

    <title>Additional groups you may want to add</title>

    <varlistentry>
      <term><literal>adm:x:&gid-adm;:root,adm,daemon</literal></term>
      <listitem>
        <para>All users in this group are allowed to do administrative tasks</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>console:x:&gid-console;:</literal></term>
      <listitem>
        <para>This group has direct access to the console</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>cdrw:x:&gid-cdrw;:</literal></term>
      <listitem>
        <para>This group is allowed to use the CDRW drive</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>mail:x:&gid-mail;:mail</literal></term>
      <listitem>
        <para>Used by MTAs (Mail Transport Agents)</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>news:x:&gid-news;:news</literal></term>
      <listitem>
        <para>Used by Network News Servers</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>users:x:&gid-users;:</literal></term>
      <listitem>
        <para>The default GID used by shadow for new users</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>nogroup:x:&gid-nogroup;:</literal></term>
      <listitem>
        <para>This is a default group used by some programs that do not
        require a group</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>nobody:x:&gid-nobody;:</literal></term>
      <listitem>
        <para>This is used by NFS</para>
      </listitem>
    </varlistentry>
  </variablelist>

  <para>The created groups are not part of any standard&mdash;they are groups
  decided on in part by the requirements of the Udev configuration in this
  chapter, and in part by common convention employed by a number of existing
  Linux distributions. The Linux Standard Base (LSB, available at <ulink
 url="http://www.linuxbase.org"/>) recommends only that, besides the group
  <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
  a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
  present. All other group names and GIDs can be chosen freely by the system
  administrator since well-written programs do not depend on GID numbers, but
  rather use the group's name.</para>

  <para>The <command>login</command>, <command>agetty</command>, and
  <command>init</command> programs (and others) use a number of log
  files to record information such as who was logged into the system and
  when. However, these programs will not write to the log files if they
  do not already exist. Initialize the log files and give them
  proper permissions:</para>

<screen><userinput>touch ${CLFS}/var/run/utmp ${CLFS}/var/log/{btmp,lastlog,wtmp}
chmod -v 664 ${CLFS}/var/run/utmp ${CLFS}/var/log/lastlog
chmod -v 600 ${CLFS}/var/log/btmp</userinput></screen>

  <para>The <filename>/var/run/utmp</filename> file records the users
  that are currently logged in. The <filename>/var/log/wtmp</filename>
  file records all logins and logouts. The
  <filename>/var/log/lastlog</filename> file records when
  each user last logged in. The <filename>/var/log/btmp</filename> file
  records the bad login attempts.</para>

</sect1>