source: chapter04/addinguser.xml@ 199d14c

11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 bdubbs/gcc13 multilib renodr/libudev-from-systemd trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 199d14c was 199d14c, checked in by Xi Ruoyao <xry111@…>, 19 months ago

addinguser: don't say "log in as lfs user"

"log in" is a specifically defined action on UNIces. When you log in
as a user, an entry will be added into /run/utmp and /var/log/wtmp.
But when you switch to lfs with "su", this won't happen.

"man su" also describes "--login" as:

Provide an environment similar to what the user would expect had
the user logged in directly.

It's "similar to" logged in, not "really" logged in.

So, don't say "log in" or the users may assume they must really log in
as lfs in a VT or DM.

  • Property mode set to 100644
File size: 4.2 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-preps-addinguser">
9 <?dbhtml filename="addinguser.html"?>
10
11 <title>Adding the LFS User</title>
12
13 <para>When logged in as user <systemitem class="username">root</systemitem>,
14 making a single mistake can damage or destroy a system. Therefore,
15 the packages in the next two chapters are built as an unprivileged user.
16 You could use your own user name, but to make it easier to set up a clean
17 working environment, we will create a new user called <systemitem
18 class="username">lfs</systemitem> as a member of a new group (also named
19 <systemitem class="groupname">lfs</systemitem>) and run commands as &lfs-user; during
20 the installation process. As <systemitem class="username">root</systemitem>,
21 issue the following commands to add the new user:</para>
22
23<screen><userinput>groupadd lfs
24useradd -s /bin/bash -g lfs -m -k /dev/null lfs</userinput></screen>
25
26 <variablelist>
27 <title>This is what the command line options mean:</title>
28
29 <varlistentry>
30 <term><parameter>-s /bin/bash</parameter></term>
31 <listitem>
32 <para>This makes <command>bash</command> the default shell for user
33 <systemitem class="username">lfs</systemitem>.</para>
34 </listitem>
35 </varlistentry>
36
37 <varlistentry>
38 <term><parameter>-g lfs</parameter></term>
39 <listitem>
40 <para>This option adds user <systemitem class="username">lfs</systemitem>
41 to group <systemitem class="groupname">lfs</systemitem>.</para>
42 </listitem>
43 </varlistentry>
44
45 <varlistentry>
46 <term><parameter>-m</parameter></term>
47 <listitem>
48 <para>This creates a home directory for <systemitem
49 class="username">lfs</systemitem>.</para>
50 </listitem>
51 </varlistentry>
52
53 <varlistentry>
54 <term><parameter>-k /dev/null</parameter></term>
55 <listitem>
56 <para>This parameter prevents possible copying of files from a skeleton
57 directory (the default is <filename class="directory">/etc/skel</filename>)
58 by changing the input location to the special null device.</para>
59 </listitem>
60 </varlistentry>
61
62 <varlistentry>
63 <term><parameter>lfs</parameter></term>
64 <listitem>
65 <para>This is the actual name for the created user.</para>
66 </listitem>
67 </varlistentry>
68
69 </variablelist>
70
71 <para>To enable logging in as <systemitem class="username">lfs</systemitem> (as opposed
72 to switching to user <systemitem class="username">lfs</systemitem> when logged
73 in as <systemitem class="username">root</systemitem>, which does not require
74 the <systemitem class="username">lfs</systemitem> user to have a password),
75 give <systemitem class="username">lfs</systemitem> a password:</para>
76
77<screen role="nodump"><userinput>passwd lfs</userinput></screen>
78
79 <para>Grant <systemitem class="username">lfs</systemitem> full access to
80 all the directories under <filename class="directory">$LFS</filename> by making
81 <systemitem class="username">lfs</systemitem> the owner:</para>
82
83<screen><userinput>chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}
84case $(uname -m) in
85 x86_64) chown -v lfs $LFS/lib64 ;;
86esac</userinput></screen>
87
88<note><para>In some host systems, the following <command>su</command> command does not complete
89 properly and suspends the login for the &lfs-user; user to the background.
90 If the prompt "lfs:~$" does not appear immediately, entering the
91 <command>fg</command> command will fix the issue.</para></note>
92
93 <para>Next, login as user <systemitem class="username">lfs</systemitem>.
94 This can be done via a virtual console, through a display manager, or with
95 the following substitute/switch user command:</para>
96
97<screen role="nodump"><userinput>su - lfs</userinput></screen>
98
99 <para>The <quote><parameter>-</parameter></quote> instructs
100 <command>su</command> to start a login shell as opposed to a non-login shell.
101 The difference between these two types of shells is described in detail in
102 <filename>bash(1)</filename> and <command>info bash</command>.</para>
103
104</sect1>
Note: See TracBrowser for help on using the repository browser.