[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[6a3b6af] | 7 |
|
---|
[afcfd74] | 8 | <sect1 id="ch-preps-addinguser">
|
---|
[6a3b6af] | 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>,
|
---|
[707c4d3] | 14 | making a single mistake can damage or destroy a system. Therefore,
|
---|
[ee714d3] | 15 | the packages in the next two chapters are built as an unprivileged user.
|
---|
[6a3b6af] | 16 | You could use your own user name, but to make it easier to set up a clean
|
---|
[ec7b0466] | 17 | working environment, we will create a new user called <systemitem
|
---|
[6a3b6af] | 18 | class="username">lfs</systemitem> as a member of a new group (also named
|
---|
[199d14c] | 19 | <systemitem class="groupname">lfs</systemitem>) and run commands as &lfs-user; during
|
---|
[6a3b6af] | 20 | the installation process. As <systemitem class="username">root</systemitem>,
|
---|
| 21 | issue the following commands to add the new user:</para>
|
---|
[673b0d8] | 22 |
|
---|
[1fd5d19] | 23 | <screen><userinput>groupadd lfs
|
---|
| 24 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs</userinput></screen>
|
---|
[673b0d8] | 25 |
|
---|
[6a3b6af] | 26 | <variablelist>
|
---|
[ec7b0466] | 27 | <title>This is what the command line options mean:</title>
|
---|
[6a3b6af] | 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
|
---|
[ec7b0466] | 57 | directory (the default is <filename class="directory">/etc/skel</filename>)
|
---|
[6a3b6af] | 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>
|
---|
[13702d9] | 65 | <para>This is the name of the new user.</para>
|
---|
[6a3b6af] | 66 | </listitem>
|
---|
| 67 | </varlistentry>
|
---|
| 68 |
|
---|
| 69 | </variablelist>
|
---|
| 70 |
|
---|
[aa9ade1] | 71 | <para>If you want to log in as &lfs-user; or switch to &lfs-user; from a
|
---|
| 72 | non-&root; user (as opposed to switching to user &lfs-user;
|
---|
| 73 | when logged in as &root;, which does not require the &lfs-user; user to
|
---|
[13702d9] | 74 | have a password), you need to set a password for &lfs-user;. Issue the
|
---|
[aa9ade1] | 75 | following command as the &root; user to set the password:</para>
|
---|
[81fd230] | 76 |
|
---|
[d7ec037] | 77 | <screen role="nodump"><userinput>passwd lfs</userinput></screen>
|
---|
[673b0d8] | 78 |
|
---|
[6a3b6af] | 79 | <para>Grant <systemitem class="username">lfs</systemitem> full access to
|
---|
[ec7b0466] | 80 | all the directories under <filename class="directory">$LFS</filename> by making
|
---|
| 81 | <systemitem class="username">lfs</systemitem> the owner:</para>
|
---|
[81fd230] | 82 |
|
---|
[d7a9421] | 83 | <screen><userinput>chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}
|
---|
[70f0882] | 84 | case $(uname -m) in
|
---|
| 85 | x86_64) chown -v lfs $LFS/lib64 ;;
|
---|
| 86 | esac</userinput></screen>
|
---|
[673b0d8] | 87 |
|
---|
[ec7b0466] | 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.
|
---|
[e286d8db] | 90 | If the prompt "lfs:~$" does not appear immediately, entering the
|
---|
[bec76ac] | 91 | <command>fg</command> command will fix the issue.</para></note>
|
---|
| 92 |
|
---|
[aa9ade1] | 93 | <para>Next, start a shell running as user &lfs-user;. This can be done by
|
---|
| 94 | logging in as &lfs-user; on a virtual console, or with the following
|
---|
| 95 | substitute/switch user command:</para>
|
---|
[81fd230] | 96 |
|
---|
[6a3b6af] | 97 | <screen role="nodump"><userinput>su - lfs</userinput></screen>
|
---|
[673b0d8] | 98 |
|
---|
[6a3b6af] | 99 | <para>The <quote><parameter>-</parameter></quote> instructs
|
---|
| 100 | <command>su</command> to start a login shell as opposed to a non-login shell.
|
---|
[ec7b0466] | 101 | The difference between these two types of shells is described in detail in
|
---|
[ea93c11] | 102 | <ulink role='man' url='&man;bash.1'>bash(1)</ulink> and <command>info
|
---|
| 103 | bash</command>.</para>
|
---|
[81fd230] | 104 |
|
---|
[673b0d8] | 105 | </sect1>
|
---|