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