1
0

addinguser.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="UTF-8"?>
  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. <sect1 id="ch-tools-addinguser">
  8. <?dbhtml filename="addinguser.html"?>
  9. <title>添加 LFS 用户</title>
  10. <!--para>When logged in as user <systemitem class="username">root</systemitem>,
  11. making a single mistake can damage or destroy a system. Therefore, we
  12. recommend building the packages in this chapter as an unprivileged user.
  13. You could use your own user name, but to make it easier to set up a clean
  14. working environment, create a new user called <systemitem
  15. class="username">lfs</systemitem> as a member of a new group (also named
  16. <systemitem class="groupname">lfs</systemitem>) and use this user during
  17. the installation process. As <systemitem class="username">root</systemitem>,
  18. issue the following commands to add the new user:</para-->
  19. <para>在作为 <systemitem class="username">root</systemitem> 用户登录时,
  20. 一个微小的错误就可能损坏甚至摧毁整个系统。
  21. 因此,我们建议以非特权用户身份编译
  22. <xref linkend="chapter-temporary-tools"/> 中的软件包。
  23. 您可以使用自己的系统用户,但为了更容易地建立一个干净的工作环境,
  24. 最好创建一个名为 <systemitem class="username">lfs</systemitem>
  25. 的新用户,以及它从属于的一个新组 (组名也是
  26. <systemitem class="groupname">lfs</systemitem>) ,
  27. 以便我们在编译过程中使用。为了创建新用户,以
  28. <systemitem class="username">root</systemitem> 身份执行以下命令:
  29. </para>
  30. <screen><userinput>groupadd lfs
  31. useradd -s /bin/bash -g lfs -m -k /dev/null lfs</userinput></screen>
  32. <variablelist>
  33. <title>命令行各选项的含义:</title>
  34. <varlistentry>
  35. <term><parameter>-s /bin/bash</parameter></term>
  36. <listitem>
  37. <para>设置 <command>bash</command> 为用户
  38. <systemitem class="username">lfs</systemitem> 的默认 shell 。</para>
  39. </listitem>
  40. </varlistentry>
  41. <varlistentry>
  42. <term><parameter>-g lfs</parameter></term>
  43. <listitem>
  44. <para>添加用户 <systemitem class="username">lfs</systemitem>
  45. 到组 <systemitem class="groupname">lfs</systemitem> 。</para>
  46. </listitem>
  47. </varlistentry>
  48. <varlistentry>
  49. <term><parameter>-m</parameter></term>
  50. <listitem>
  51. <para>为用户 <systemitem
  52. class="username">lfs</systemitem> 创建一个主目录。</para>
  53. </listitem>
  54. </varlistentry>
  55. <varlistentry>
  56. <term><parameter>-k /dev/null</parameter></term>
  57. <listitem>
  58. <para>将模板目录设置为空设备文件,从而不从默认模板目录
  59. (<filename class="directory">/etc/skel</filename>)
  60. 复制文件到新的主目录。</para>
  61. </listitem>
  62. </varlistentry>
  63. <varlistentry>
  64. <term><parameter>lfs</parameter></term>
  65. <listitem>
  66. <para>要创建的用户和组的名称。</para>
  67. </listitem>
  68. </varlistentry>
  69. </variablelist>
  70. <!--para>To log in as <systemitem class="username">lfs</systemitem> (as opposed
  71. to switching to user <systemitem class="username">lfs</systemitem> when logged
  72. in as <systemitem class="username">root</systemitem>, which does not require
  73. the <systemitem class="username">lfs</systemitem> user to have a password),
  74. give <systemitem class="username">lfs</systemitem> a password:</para-->
  75. <para>为了以 <systemitem class="username">lfs</systemitem> 身份登录系统
  76. (尽管以 <systemitem class="username">root</systemitem>
  77. 身份登录时可以不用输入密码,直接切换到用户
  78. <systemitem class="username">lfs</systemitem>),
  79. 为 <systemitem class="username">lfs</systemitem> 设置密码:</para>
  80. <screen role="nodump"><userinput>passwd lfs</userinput></screen>
  81. <!--para>Grant <systemitem class="username">lfs</systemitem> full access to
  82. <filename class="directory">$LFS/tools</filename> by making
  83. <systemitem class="username">lfs</systemitem> the directory owner:</para-->
  84. <para>将 <systemitem class="username">lfs</systemitem> 设为
  85. <filename class="directory">$LFS/tools</filename> 目录的所有者,
  86. 使 <systemitem class="username">lfs</systemitem>
  87. 对这个目录拥有完全访问权:</para>
  88. <screen><userinput>chown -v lfs $LFS/tools</userinput></screen>
  89. <!--para>If a separate working directory was created as suggested, give
  90. user <systemitem class="username">lfs</systemitem> ownership of this
  91. directory:</para-->
  92. <para>如果您按照本书的建议,建立了一个单独的工作目录,
  93. 那么将这个目录的所有者也设为
  94. <systemitem class="username">lfs</systemitem>:</para>
  95. <screen><userinput>chown -v lfs $LFS/sources</userinput></screen>
  96. <!--para>Next, login as user <systemitem class="username">lfs</systemitem>.
  97. This can be done via a virtual console, through a display manager, or with
  98. the following substitute user command:</para-->
  99. <para>下面以 <systemitem class="username">lfs</systemitem> 的身份登录。
  100. 可以在显示管理器中的虚拟控制台登录,也可以使用下面的命令切换用户:
  101. </para>
  102. <screen role="nodump"><userinput>su - lfs</userinput></screen>
  103. <!--para>The <quote><parameter>-</parameter></quote> instructs
  104. <command>su</command> to start a login shell as opposed to a non-login shell.
  105. The difference between these two types of shells can be found in detail in
  106. <filename>bash(1)</filename> and <command>info bash</command>.</para-->
  107. <para>参数 <quote><parameter>-</parameter></quote> 使得
  108. <command>su</command> 启动一个登录 shell ,而不是非登录 shell 。
  109. 您可以阅读
  110. <filename>bash(1)</filename> 和 <command>info bash</command>
  111. 详细了解它们的区别。</para>
  112. </sect1>