mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-01-18 04:57:38 +00:00
6528f75720
The preceding commit uses <systemitem> elements to mark the lfs user and group in commands. Unfortunately, this change the rendering in html, because now lfs appears in an italic font. Using <userinput remap='group'> or <userinput remap='user'> allows parsing the XML for jhalfs, but does not change the html rendering.
106 lines
4.2 KiB
XML
106 lines
4.2 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!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-preps-addinguser">
|
|
<?dbhtml filename="addinguser.html"?>
|
|
|
|
<title>Adding the LFS User</title>
|
|
|
|
<para>When logged in as user <systemitem class="username">root</systemitem>,
|
|
making a single mistake can damage or destroy a system. Therefore,
|
|
the packages in the next two chapters are built as an unprivileged user.
|
|
You could use your own user name, but to make it easier to set up a clean
|
|
working environment, we will create a new user called <systemitem
|
|
class="username">lfs</systemitem> as a member of a new group (also named
|
|
<systemitem class="groupname">lfs</systemitem>) and run commands as &lfs-user; during
|
|
the installation process. As <systemitem class="username">root</systemitem>,
|
|
issue the following commands to add the new user:</para>
|
|
|
|
<screen><userinput>groupadd &lfs-groupname;
|
|
useradd -s /bin/bash -g &lfs-groupname; -m -k /dev/null &lfs-username;</userinput></screen>
|
|
|
|
<variablelist>
|
|
<title>This is what the command line options mean:</title>
|
|
|
|
<varlistentry>
|
|
<term><parameter>-s /bin/bash</parameter></term>
|
|
<listitem>
|
|
<para>This makes <command>bash</command> the default shell for user
|
|
<systemitem class="username">lfs</systemitem>.</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>-g lfs</parameter></term>
|
|
<listitem>
|
|
<para>This option adds user <systemitem class="username">lfs</systemitem>
|
|
to group <systemitem class="groupname">lfs</systemitem>.</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>-m</parameter></term>
|
|
<listitem>
|
|
<para>This creates a home directory for <systemitem
|
|
class="username">lfs</systemitem>.</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>-k /dev/null</parameter></term>
|
|
<listitem>
|
|
<para>This parameter prevents possible copying of files from a skeleton
|
|
directory (the default is <filename class="directory">/etc/skel</filename>)
|
|
by changing the input location to the special null device.</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><parameter>lfs</parameter></term>
|
|
<listitem>
|
|
<para>This is the name of the new user.</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
<para>If you want to log in as &lfs-user; or switch to &lfs-user; from a
|
|
non-&root; user (as opposed to switching to user &lfs-user;
|
|
when logged in as &root;, which does not require the &lfs-user; user to
|
|
have a password), you need to set a password for &lfs-user;. Issue the
|
|
following command as the &root; user to set the password:</para>
|
|
|
|
<screen role="nodump"><userinput>passwd &lfs-username;</userinput></screen>
|
|
|
|
<para>Grant <systemitem class="username">lfs</systemitem> full access to
|
|
all the directories under <filename class="directory">$LFS</filename> by making
|
|
<systemitem class="username">lfs</systemitem> the owner:</para>
|
|
|
|
<screen><userinput>chown -v &lfs-username; $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}
|
|
case $(uname -m) in
|
|
x86_64) chown -v &lfs-username; $LFS/lib64 ;;
|
|
esac</userinput></screen>
|
|
|
|
<note><para>In some host systems, the following <command>su</command> command does not complete
|
|
properly and suspends the login for the &lfs-user; user to the background.
|
|
If the prompt "lfs:~$" does not appear immediately, entering the
|
|
<command>fg</command> command will fix the issue.</para></note>
|
|
|
|
<para>Next, start a shell running as user &lfs-user;. This can be done by
|
|
logging in as &lfs-user; on a virtual console, or with the following
|
|
substitute/switch user command:</para>
|
|
|
|
<screen role="nodump"><userinput>su - &lfs-username;</userinput></screen>
|
|
|
|
<para>The <quote><parameter>-</parameter></quote> instructs
|
|
<command>su</command> to start a login shell as opposed to a non-login shell.
|
|
The difference between these two types of shells is described in detail in
|
|
<ulink role='man' url='&man;bash.1'>bash(1)</ulink> and <command>info
|
|
bash</command>.</para>
|
|
|
|
</sect1>
|