mirror of
https://github.com/LCTT/LFS-BOOK-7.7-systemd.git
synced 2026-01-14 00:49:09 +00:00
355 lines
13 KiB
HTML
355 lines
13 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content=
|
|
"application/xhtml+xml; charset=utf-8" />
|
|
<title>
|
|
6.6. Creating Essential Files and Symlinks
|
|
</title>
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
|
|
<link rel="stylesheet" href="stylesheets/lfs-print.css" type="text/css"
|
|
media="print" />
|
|
</head>
|
|
<body class="lfs" id="lfs-7.7-systemd">
|
|
<div class="navheader">
|
|
<h4>
|
|
Linux From Scratch - Version 7.7-systemd
|
|
</h4>
|
|
<h3>
|
|
Chapter 6. Installing Basic System Software
|
|
</h3>
|
|
<ul>
|
|
<li class="prev">
|
|
<a accesskey="p" href="creatingdirs.html" title=
|
|
"Creating Directories">Prev</a>
|
|
<p>
|
|
Creating Directories
|
|
</p>
|
|
</li>
|
|
<li class="next">
|
|
<a accesskey="n" href="linux-headers.html" title=
|
|
"Linux-3.19 API Headers">Next</a>
|
|
<p>
|
|
Linux-3.19 API Headers
|
|
</p>
|
|
</li>
|
|
<li class="up">
|
|
<a accesskey="u" href="chapter06.html" title=
|
|
"Chapter 6. Installing Basic System Software">Up</a>
|
|
</li>
|
|
<li class="home">
|
|
<a accesskey="h" href="../index.html" title=
|
|
"Linux From Scratch - Version 7.7-systemd">Home</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="sect1" lang="en" xml:lang="en">
|
|
<h1 class="sect1">
|
|
<a id="ch-system-createfiles" name="ch-system-createfiles"></a>6.6.
|
|
Creating Essential Files and Symlinks
|
|
</h1>
|
|
<p>
|
|
Some programs use hard-wired paths to programs which do not exist
|
|
yet. In order to satisfy these programs, create a number of symbolic
|
|
links which will be replaced by real files throughout the course of
|
|
this chapter after the software has been installed:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
|
|
ln -sv /tools/bin/perl /usr/bin
|
|
ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
|
ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
|
|
sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
|
|
ln -sv bash /bin/sh</kbd>
|
|
</pre>
|
|
<div class="variablelist">
|
|
<p class="title">
|
|
<strong>The purpose of each link:</strong>
|
|
</p>
|
|
<dl class="variablelist">
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/bash</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
Many <span class="command"><strong>bash</strong></span> scripts
|
|
specify <code class="filename">/bin/bash</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/cat</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
This pathname is hard-coded into Glibc's configure script.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/echo</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
This is to satisfy one of the tests in Glibc's test suite,
|
|
which expects <code class="filename">/bin/echo</code>.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/pwd</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
Some <span class="command"><strong>configure</strong></span>
|
|
scripts, particularly Glibc's, have this pathname hard-coded.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/stty</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
This pathname is hard-coded into Expect, therefore it is needed
|
|
for Binutils and GCC test suites to pass.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/usr/bin/perl</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
Many Perl scripts hard-code this path to the <span class=
|
|
"command"><strong>perl</strong></span> program.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/usr/lib/libgcc_s.so{,.1}</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
Glibc needs this for the pthreads library to work.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/usr/lib/libstdc++{,.6}</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
This is needed by several tests in Glibc's test suite, as well
|
|
as for C++ support in GMP.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/usr/lib/libstdc++.la</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
This prevents a <code class="filename">/tools</code> reference
|
|
that would otherwise be in <code class=
|
|
"filename">/usr/lib/libstdc++.la</code> after GCC is installed.
|
|
</p>
|
|
</dd>
|
|
<dt>
|
|
<span class="term"><em class="parameter"><code><code class=
|
|
"filename">/bin/sh</code></code></em></span>
|
|
</dt>
|
|
<dd>
|
|
<p>
|
|
Many shell scripts hard-code <code class=
|
|
"filename">/bin/sh</code>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<p>
|
|
Historically, Linux maintains a list of the mounted file systems in
|
|
the file <code class="filename">/etc/mtab</code>. Modern kernels
|
|
maintain this list internally and exposes it to the user via the
|
|
<code class="filename">/proc</code> filesystem. To satisfy utilities
|
|
that expect the presence of <code class="filename">/etc/mtab</code>,
|
|
create the following symbolic link:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">ln -sv /proc/self/mounts /etc/mtab</kbd>
|
|
</pre>
|
|
<p>
|
|
In order for user <code class="systemitem">root</code> to be able to
|
|
login and for the name <span class="quote">“<span class=
|
|
"quote">root</span>”</span> to be recognized, there must be
|
|
relevant entries in the <code class="filename">/etc/passwd</code> and
|
|
<code class="filename">/etc/group</code> files.
|
|
</p>
|
|
<p>
|
|
Create the <code class="filename">/etc/passwd</code> file by running
|
|
the following command:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">cat > /etc/passwd << "EOF"
|
|
<code class="literal">root:x:0:0:root:/root:/bin/bash
|
|
bin:x:1:1:bin:/dev/null:/bin/false
|
|
daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
|
messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
|
systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
|
|
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
|
|
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
|
|
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
|
|
systemd-network:x:76:76:systemd Network Management:/:/bin/false
|
|
systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
|
|
systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
|
|
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</code>
|
|
EOF</kbd>
|
|
</pre>
|
|
<p>
|
|
The actual password for <code class="systemitem">root</code> (the
|
|
<span class="quote">“<span class="quote">x</span>”</span>
|
|
used here is just a placeholder) will be set later.
|
|
</p>
|
|
<p>
|
|
Create the <code class="filename">/etc/group</code> file by running
|
|
the following command:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">cat > /etc/group << "EOF"
|
|
<code class="literal">root:x:0:
|
|
bin:x:1:daemon
|
|
sys:x:2:
|
|
kmem:x:3:
|
|
tape:x:4:
|
|
tty:x:5:
|
|
daemon:x:6:
|
|
floppy:x:7:
|
|
disk:x:8:
|
|
lp:x:9:
|
|
dialout:x:10:
|
|
audio:x:11:
|
|
video:x:12:
|
|
utmp:x:13:
|
|
usb:x:14:
|
|
cdrom:x:15:
|
|
adm:x:16:
|
|
messagebus:x:18:
|
|
systemd-journal:x:23:
|
|
input:x:24:
|
|
mail:x:34:
|
|
systemd-bus-proxy:x:72:
|
|
systemd-journal-gateway:x:73:
|
|
systemd-journal-remote:x:74:
|
|
systemd-journal-upload:x:75:
|
|
systemd-network:x:76:
|
|
systemd-resolve:x:77:
|
|
systemd-timesync:x:78:
|
|
nogroup:x:99:
|
|
users:x:999:</code>
|
|
EOF</kbd>
|
|
</pre>
|
|
<p>
|
|
The created groups are not part of any standard—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. In addition, some test suites rely
|
|
on specific users or groups. The Linux Standard Base (LSB, available
|
|
at <a class="ulink" href=
|
|
"http://www.linuxbase.org">http://www.linuxbase.org</a>) recommends
|
|
only that, besides the group <code class="systemitem">root</code>
|
|
with a Group ID (GID) of 0, a group <code class=
|
|
"systemitem">bin</code> 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.
|
|
</p>
|
|
<p>
|
|
To remove the <span class="quote">“<span class="quote">I have
|
|
no name!</span>”</span> prompt, start a new shell. Since a full
|
|
Glibc was installed in <a class="xref" href=
|
|
"../chapter05/chapter05.html" title=
|
|
"Chapter 5. Constructing a Temporary System">Chapter 5</a>
|
|
and the <code class="filename">/etc/passwd</code> and <code class=
|
|
"filename">/etc/group</code> files have been created, user name and
|
|
group name resolution will now work:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">exec /tools/bin/bash --login +h</kbd>
|
|
</pre>
|
|
<p>
|
|
Note the use of the <em class="parameter"><code>+h</code></em>
|
|
directive. This tells <span class=
|
|
"command"><strong>bash</strong></span> not to use its internal path
|
|
hashing. Without this directive, <span class=
|
|
"command"><strong>bash</strong></span> would remember the paths to
|
|
binaries it has executed. To ensure the use of the newly compiled
|
|
binaries as soon as they are installed, the <em class=
|
|
"parameter"><code>+h</code></em> directive will be used for the
|
|
duration of this chapter.
|
|
</p>
|
|
<p>
|
|
The <span class="command"><strong>login</strong></span>, <span class=
|
|
"command"><strong>agetty</strong></span>, and <span class=
|
|
"command"><strong>init</strong></span> 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:
|
|
</p>
|
|
<pre class="userinput">
|
|
<kbd class="command">touch /var/log/{btmp,lastlog,wtmp}
|
|
chgrp -v utmp /var/log/lastlog
|
|
chmod -v 664 /var/log/lastlog
|
|
chmod -v 600 /var/log/btmp</kbd>
|
|
</pre>
|
|
<p>
|
|
The <code class="filename">/var/log/wtmp</code> file records all
|
|
logins and logouts. The <code class=
|
|
"filename">/var/log/lastlog</code> file records when each user last
|
|
logged in. The <code class="filename">/var/log/btmp</code> file
|
|
records the bad login attempts.
|
|
</p>
|
|
<div class="admon note">
|
|
<img alt="[Note]" src="../images/note.png" />
|
|
<h3>
|
|
Note
|
|
</h3>
|
|
<p>
|
|
The <code class="filename">/run/utmp</code> file records the users
|
|
that are currently logged in. This file is created dynamically in
|
|
the boot scripts.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="navfooter">
|
|
<ul>
|
|
<li class="prev">
|
|
<a accesskey="p" href="creatingdirs.html" title=
|
|
"Creating Directories">Prev</a>
|
|
<p>
|
|
Creating Directories
|
|
</p>
|
|
</li>
|
|
<li class="next">
|
|
<a accesskey="n" href="linux-headers.html" title=
|
|
"Linux-3.19 API Headers">Next</a>
|
|
<p>
|
|
Linux-3.19 API Headers
|
|
</p>
|
|
</li>
|
|
<li class="up">
|
|
<a accesskey="u" href="chapter06.html" title=
|
|
"Chapter 6. Installing Basic System Software">Up</a>
|
|
</li>
|
|
<li class="home">
|
|
<a accesskey="h" href="../index.html" title=
|
|
"Linux From Scratch - Version 7.7-systemd">Home</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|