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