[f8d632ac] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[ff769b8c] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[f8d632ac] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
[0290a023] | 8 | <sect1 id="postlfs-config-skel" xreflabel="Configuring for Adding Users">
|
---|
[991aa6f] | 9 | <?dbhtml filename="skel.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>Configuring for Adding Users</title>
|
---|
| 17 |
|
---|
| 18 | <indexterm zone="postlfs-config-skel">
|
---|
| 19 | <primary sortas="e-etc-skel">/etc/skel/*</primary>
|
---|
| 20 | </indexterm>
|
---|
| 21 |
|
---|
| 22 | <indexterm zone="postlfs-config-skel">
|
---|
| 23 | <primary sortas="e-etc-default-useradd">/etc/default/useradd</primary>
|
---|
| 24 | </indexterm>
|
---|
| 25 |
|
---|
| 26 | <para>Together, the <command>/usr/sbin/useradd</command> command and
|
---|
[e0d33ef] | 27 | <filename class="directory">/etc/skel</filename> directory (both are easy to
|
---|
[9e4bed20] | 28 | set up and use) provide a way to assure new users are added to your LFS
|
---|
| 29 | system with the same beginning settings for things such as the
|
---|
| 30 | <envar>PATH</envar>, keyboard processing and other environmental variables.
|
---|
| 31 | Using these two facilities makes it easier to assure this initial state for
|
---|
| 32 | each new user added to the system.</para>
|
---|
[991aa6f] | 33 |
|
---|
[e0d33ef] | 34 | <para>The <filename class="directory">/etc/skel</filename> directory holds
|
---|
| 35 | copies of various initialization and other files that may be copied to the
|
---|
[d612b9f] | 36 | new user's home directory when the <command>/usr/sbin/useradd</command>
|
---|
[991aa6f] | 37 | program adds the new user.</para>
|
---|
| 38 |
|
---|
| 39 | <bridgehead renderas="sect5">Useradd</bridgehead>
|
---|
| 40 |
|
---|
| 41 | <para>The <command>useradd</command> program uses a collection of
|
---|
| 42 | default values kept in <filename>/etc/default/useradd</filename>,
|
---|
[9e4bed20] | 43 | if it exists. If this file does not exist, then it uses some internal
|
---|
[e0d33ef] | 44 | defaults. You can see the default values by running
|
---|
[991aa6f] | 45 | <command>/usr/sbin/useradd -D</command>.</para>
|
---|
| 46 |
|
---|
[9e4bed20] | 47 | <para>To change these values to something new, create a base
|
---|
| 48 | <filename>/etc/default/useradd</filename> file as the
|
---|
| 49 | <systemitem class='username'>root</systemitem> user with the same values as
|
---|
| 50 | the output of <command>/usr/sbin/useradd -D</command>. Here is a
|
---|
| 51 | sample:</para>
|
---|
[991aa6f] | 52 |
|
---|
| 53 | <screen><literal># Begin /etc/default/useradd
|
---|
[7346f16] | 54 |
|
---|
| 55 | GROUP=100
|
---|
| 56 | HOME=/home
|
---|
| 57 | INACTIVE=-1
|
---|
| 58 | EXPIRE=
|
---|
| 59 | SHELL=
|
---|
| 60 | SKEL=/etc/skel
|
---|
| 61 |
|
---|
[991aa6f] | 62 | # End /etc/default/useradd</literal></screen>
|
---|
| 63 |
|
---|
| 64 | <para>The only thing missing from the file is a default shell. Add that
|
---|
[9e4bed20] | 65 | by running the following command as the
|
---|
| 66 | <systemitem class='username'>root</systemitem> user:</para>
|
---|
[991aa6f] | 67 |
|
---|
| 68 | <screen role="root"><userinput>/usr/sbin/useradd -D -s/bin/bash</userinput></screen>
|
---|
| 69 |
|
---|
[e0d33ef] | 70 | <para>This will set the <envar>SHELL</envar>= line to
|
---|
[991aa6f] | 71 | <envar>SHELL</envar>=/bin/bash.</para>
|
---|
| 72 |
|
---|
[9e4bed20] | 73 | <para><command>useradd</command> has many parameters that
|
---|
| 74 | can be set in the <filename>/etc/default/useradd</filename> file. For more
|
---|
| 75 | information see <command>man useradd</command>.</para>
|
---|
[991aa6f] | 76 |
|
---|
| 77 | <bridgehead renderas="sect5">/etc/skel</bridgehead>
|
---|
| 78 |
|
---|
[9e4bed20] | 79 | <para>To get started, create an
|
---|
| 80 | <filename class="directory">/etc/skel</filename> directory and make sure it
|
---|
| 81 | is writable only by the system administrator, usually
|
---|
| 82 | <systemitem class="username">root</systemitem>. Creating the directory as
|
---|
| 83 | <systemitem class="username">root</systemitem> is the best way to go.</para>
|
---|
[991aa6f] | 84 |
|
---|
| 85 | <para>The mode of any files from this part of the book that you put in
|
---|
[e0d33ef] | 86 | <filename class="directory">/etc/skel</filename> should be writable only by
|
---|
| 87 | the owner. Also, since there is no telling what kind of sensitive information
|
---|
[991aa6f] | 88 | a user may eventually place in their copy of these files, you should
|
---|
| 89 | make them unreadable by "group" and "other".</para>
|
---|
| 90 |
|
---|
[e0d33ef] | 91 | <para>You can also put other files in
|
---|
[991aa6f] | 92 | <filename class="directory">/etc/skel</filename> and
|
---|
| 93 | different permissions may be needed for them.</para>
|
---|
| 94 |
|
---|
| 95 | <para>Decide which initialization files should be provided in every (or most)
|
---|
| 96 | new user's home directory. The decisions you make will affect what you
|
---|
[e0d33ef] | 97 | do in the next two sections, <xref linkend="postlfs-config-profile"/> and
|
---|
[991aa6f] | 98 | <xref linkend="postlfs-config-vimrc"/>. Some or all of those files will be
|
---|
[e0d33ef] | 99 | useful for <systemitem class="username">root</systemitem>, any
|
---|
[991aa6f] | 100 | already-existing users, and new users.</para>
|
---|
| 101 |
|
---|
| 102 | <para>The files from those sections that you might want to place in
|
---|
| 103 | <filename class="directory">/etc/skel</filename> include
|
---|
| 104 | <filename>.inputrc</filename>, <filename>.bash_profile</filename>,
|
---|
| 105 | <filename>.bashrc</filename>, <filename>.bash_logout</filename>,
|
---|
| 106 | <filename>.dircolors</filename>, and <filename>.vimrc</filename>. If
|
---|
| 107 | you are unsure which of these should be placed there, just continue to
|
---|
| 108 | the following sections, read each section and any references provided,
|
---|
| 109 | and then make your decision.</para>
|
---|
| 110 |
|
---|
| 111 | <para>You will run a slightly modified set of commands for files which
|
---|
[e0d33ef] | 112 | are placed in <filename class="directory">/etc/skel</filename>. Each section
|
---|
| 113 | will remind you of this. In brief, the book's commands have been written for
|
---|
| 114 | files <emphasis>not</emphasis> added to
|
---|
[9e4bed20] | 115 | <filename class="directory">/etc/skel</filename> and instead just sends the
|
---|
| 116 | results to the user's home directory. If the file is going to be in
|
---|
[e0d33ef] | 117 | <filename class="directory">/etc/skel</filename>, change the book's command(s)
|
---|
[991aa6f] | 118 | to send output there instead and then just copy the file from
|
---|
[e0d33ef] | 119 | <filename class="directory">/etc/skel</filename> to the appropriate
|
---|
| 120 | directories, like <filename class="directory">/etc</filename>,
|
---|
| 121 | <filename class="directory">~</filename> or the home directory
|
---|
[991aa6f] | 122 | of any other user already in the system.</para>
|
---|
| 123 |
|
---|
| 124 | <bridgehead renderas="sect5">When Adding a User</bridgehead>
|
---|
| 125 |
|
---|
| 126 | <para>When adding a new user with <command>useradd</command>, use
|
---|
| 127 | the <option>-m</option> parameter, which tells
|
---|
| 128 | <command>useradd</command> to create the user's home directory and
|
---|
[e0d33ef] | 129 | copy files from <filename class="directory">/etc/skel</filename> (can be
|
---|
[9e4bed20] | 130 | overridden) to the new user's home directory. For example (perform as the
|
---|
| 131 | <systemitem class="username">root</systemitem> user):</para>
|
---|
[991aa6f] | 132 |
|
---|
| 133 | <screen role="root"><userinput>useradd -m <replaceable>[newuser]</replaceable></userinput></screen>
|
---|
[9a67723] | 134 |
|
---|
| 135 | </sect1>
|
---|