source: clfs-embedded/BOOK/final-system/common/creatingfiles.xml@ fa71d19

Last change on this file since fa71d19 was 73c0570, checked in by Andrew Bradford <andrew@…>, 11 years ago

creatingfiles: Reduce users and groups to minimum

  • Property mode set to 100644
File size: 3.9 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-final-system-creatingfiles">
9 <?dbhtml filename="creatingfiles.html"?>
10
11 <title>Creating the passwd, group, and log Files</title>
12
13 <indexterm zone="ch-final-system-creatingfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-final-system-creatingfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-final-system-creatingfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-final-system-creatingfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-final-system-creatingfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-final-system-creatingfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
36
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
41<screen><userinput>ln -svf ../proc/mounts ${CLFS}/targetfs/etc/mtab</userinput></screen>
42
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
51<screen><userinput>cat &gt; ${CLFS}/targetfs/etc/passwd &lt;&lt; "EOF"
52<literal>root::0:0:root:/root:/bin/ash</literal>
53EOF</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
62<screen><userinput>cat &gt; ${CLFS}/targetfs/etc/group &lt;&lt; "EOF"
63<literal>root:x:0:
64bin:x:1:
65users:x:1000:
66nogroup:x:65533:
67nobody:x:65534:</literal>
68EOF</userinput></screen>
69
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>
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
86<screen><userinput>touch ${CLFS}/targetfs/var/run/utmp ${CLFS}/targetfs/var/log/{btmp,lastlog,wtmp}
87chmod -v 664 ${CLFS}/targetfs/var/run/utmp ${CLFS}/targetfs/var/log/lastlog</userinput></screen>
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>
Note: See TracBrowser for help on using the repository browser.