123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?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-tools-addinguser">
- <?dbhtml filename="addinguser.html"?>
- <title>添加 LFS 用户</title>
- <!--para>When logged in as user <systemitem class="username">root</systemitem>,
- making a single mistake can damage or destroy a system. Therefore, we
- recommend building the packages in this chapter as an unprivileged user.
- You could use your own user name, but to make it easier to set up a clean
- working environment, 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 use this user during
- the installation process. As <systemitem class="username">root</systemitem>,
- issue the following commands to add the new user:</para-->
- <para>在作为 <systemitem class="username">root</systemitem> 用户登录时,
- 一个微小的错误就可能损坏甚至摧毁整个系统。
- 因此,我们建议以非特权用户身份编译
- <xref linkend="chapter-temporary-tools"/> 中的软件包。
- 您可以使用自己的系统用户,但为了更容易地建立一个干净的工作环境,
- 最好创建一个名为 <systemitem class="username">lfs</systemitem>
- 的新用户,以及它从属于的一个新组 (组名也是
- <systemitem class="groupname">lfs</systemitem>) ,
- 以便我们在编译过程中使用。为了创建新用户,以
- <systemitem class="username">root</systemitem> 身份执行以下命令:
- </para>
- <screen><userinput>groupadd lfs
- useradd -s /bin/bash -g lfs -m -k /dev/null lfs</userinput></screen>
- <variablelist>
- <title>命令行各选项的含义:</title>
- <varlistentry>
- <term><parameter>-s /bin/bash</parameter></term>
- <listitem>
- <para>设置 <command>bash</command> 为用户
- <systemitem class="username">lfs</systemitem> 的默认 shell 。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>-g lfs</parameter></term>
- <listitem>
- <para>添加用户 <systemitem class="username">lfs</systemitem>
- 到组 <systemitem class="groupname">lfs</systemitem> 。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>-m</parameter></term>
- <listitem>
- <para>为用户 <systemitem
- class="username">lfs</systemitem> 创建一个主目录。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>-k /dev/null</parameter></term>
- <listitem>
- <para>将模板目录设置为空设备文件,从而不从默认模板目录
- (<filename class="directory">/etc/skel</filename>)
- 复制文件到新的主目录。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>lfs</parameter></term>
- <listitem>
- <para>要创建的用户和组的名称。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <!--para>To log in as <systemitem class="username">lfs</systemitem> (as opposed
- to switching to user <systemitem class="username">lfs</systemitem> when logged
- in as <systemitem class="username">root</systemitem>, which does not require
- the <systemitem class="username">lfs</systemitem> user to have a password),
- give <systemitem class="username">lfs</systemitem> a password:</para-->
- <para>为了以 <systemitem class="username">lfs</systemitem> 身份登录系统
- (尽管以 <systemitem class="username">root</systemitem>
- 身份登录时可以不用输入密码,直接切换到用户
- <systemitem class="username">lfs</systemitem>),
- 为 <systemitem class="username">lfs</systemitem> 设置密码:</para>
- <screen role="nodump"><userinput>passwd lfs</userinput></screen>
- <!--para>Grant <systemitem class="username">lfs</systemitem> full access to
- <filename class="directory">$LFS/tools</filename> by making
- <systemitem class="username">lfs</systemitem> the directory owner:</para-->
- <para>将 <systemitem class="username">lfs</systemitem> 设为
- <filename class="directory">$LFS/tools</filename> 目录的所有者,
- 使 <systemitem class="username">lfs</systemitem>
- 对这个目录拥有完全访问权:</para>
- <screen><userinput>chown -v lfs $LFS/tools</userinput></screen>
- <!--para>If a separate working directory was created as suggested, give
- user <systemitem class="username">lfs</systemitem> ownership of this
- directory:</para-->
- <para>如果您按照本书的建议,建立了一个单独的工作目录,
- 那么将这个目录的所有者也设为
- <systemitem class="username">lfs</systemitem>:</para>
- <screen><userinput>chown -v lfs $LFS/sources</userinput></screen>
- <!--para>Next, login as user <systemitem class="username">lfs</systemitem>.
- This can be done via a virtual console, through a display manager, or with
- the following substitute user command:</para-->
- <para>下面以 <systemitem class="username">lfs</systemitem> 的身份登录。
- 可以在显示管理器中的虚拟控制台登录,也可以使用下面的命令切换用户:
- </para>
- <screen role="nodump"><userinput>su - lfs</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 can be found in detail in
- <filename>bash(1)</filename> and <command>info bash</command>.</para-->
- <para>参数 <quote><parameter>-</parameter></quote> 使得
- <command>su</command> 启动一个登录 shell ,而不是非登录 shell 。
- 您可以阅读
- <filename>bash(1)</filename> 和 <command>info bash</command>
- 详细了解它们的区别。</para>
- </sect1>
|