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