source: chapter06/createfiles.xml@ 28b40e2

Last change on this file since 28b40e2 was 28b40e2, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Finished the PDF fixes.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/6.2/BOOK@7737 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 5.4 KB
Line 
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
8<sect1 id="ch-system-createfiles">
9 <?dbhtml filename="createfiles.html"?>
10
11 <title>Creating Essential Files and Symlinks</title>
12
13 <indexterm zone="ch-system-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-system-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-system-createfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-system-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
36
37 <para>Some programs use hard-wired paths to programs which do not exist yet. In
38 order to satisfy these programs, create a number of symbolic links which will be
39 replaced by real files throughout the course of this chapter after the software
40 has been installed.</para>
41
42<screen><userinput>ln -sv /tools/bin/{bash,cat,grep,pwd,stty} /bin
43ln -sv /tools/bin/perl /usr/bin
44ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
45ln -sv bash /bin/sh</userinput></screen>
46
47 <para>A proper Linux system maintains a list of the mounted file systems in
48 the file <filename>/etc/mtab</filename>. Normally, this file would be
49 created when we mount a new file system. Since we will not be mounting any
50 file systems inside our chroot environment, create an empty file for
51 utilities that expect the presence of <filename>/etc/mtab</filename>:</para>
52
53<screen><userinput>touch /etc/mtab</userinput></screen>
54
55 <para>In order for user <systemitem class="username">root</systemitem> to be
56 able to login and for the name <quote>root</quote> to be recognized, there
57 must be relevant entries in the <filename>/etc/passwd</filename> and
58 <filename>/etc/group</filename> files.</para>
59
60 <para>Create the <filename>/etc/passwd</filename> file by running the following
61 command:</para>
62
63<screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
64<literal>root:x:0:0:root:/root:/bin/bash</literal>
65EOF</userinput></screen>
66
67 <para>The actual password for <systemitem class="username">root</systemitem>
68 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
69
70 <para>Create the <filename>/etc/group</filename> file by running the following
71 command:</para>
72
73<screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
74<literal>root:x:0:
75bin:x:1:
76sys:x:2:
77kmem:x:3:
78tty:x:4:
79tape:x:5:
80daemon:x:6:
81floppy:x:7:
82disk:x:8:
83lp:x:9:
84dialout:x:10:
85audio:x:11:
86video:x:12:
87utmp:x:13:
88usb:x:14:
89cdrom:x:15:</literal>
90EOF</userinput></screen>
91
92 <beginpage/>
93
94 <para>The created groups are not part of any standard&mdash;they are groups
95 decided on in part by the requirements of the Udev configuration in this
96 chapter, and in part by common convention employed by a number of existing
97 Linux distributions. The Linux Standard Base (LSB, available at <ulink
98 url="http://www.linuxbase.org"/>) recommends only that, besides the group
99 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
100 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
101 present. All other group names and GIDs can be chosen freely by the system
102 administrator since well-written programs do not depend on GID numbers, but
103 rather use the group's name.</para>
104
105 <para>To remove the <quote>I have no name!</quote> prompt, start a new
106 shell. Since a full Glibc was installed in <xref
107 linkend="chapter-temporary-tools"/> and the
108 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
109 files have been created, user name and group name resolution will now
110 work.</para>
111
112<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
113
114 <para>Note the use of the <parameter>+h</parameter> directive. This tells
115 <command>bash</command> not to use its internal path hashing. Without this
116 directive, <command>bash</command> would remember the paths to binaries it has
117 executed. To ensure the use of the newly compiled binaries as soon as they are
118 installed, the <parameter>+h</parameter> directive will be used for the duration
119 of this chapter.</para>
120
121 <para>The <command>login</command>, <command>agetty</command>, and
122 <command>init</command> programs (and others) use a number of log
123 files to record information such as who was logged into the system and
124 when. However, these programs will not write to the log files if they
125 do not already exist. Initialize the log files and give them
126 proper permissions:</para>
127
128<screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
129chgrp -v utmp /var/run/utmp /var/log/lastlog
130chmod -v 664 /var/run/utmp /var/log/lastlog</userinput></screen>
131
132 <para>The <filename>/var/run/utmp</filename> file records the users
133 that are currently logged in. The <filename>/var/log/wtmp</filename>
134 file records all logins and logouts. The
135 <filename>/var/log/lastlog</filename> file records when
136 each user last logged in. The <filename>/var/log/btmp</filename> file
137 records the bad login attempts.</para>
138
139</sect1>
Note: See TracBrowser for help on using the repository browser.