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 |
|
---|
8 | <sect1 id="postlfs-config-skel" xreflabel="Configuring for Adding Users">
|
---|
9 | <sect1info>
|
---|
10 | <othername>$LastChangedBy$</othername>
|
---|
11 | <date>$Date$</date>
|
---|
12 | </sect1info>
|
---|
13 | <?dbhtml filename="skel.html"?>
|
---|
14 | <title>Configuring for Adding Users</title>
|
---|
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>
|
---|
20 |
|
---|
21 | <para>Together, the <command>/usr/sbin/useradd</command> command and
|
---|
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>
|
---|
33 |
|
---|
34 | <para><emphasis>Useradd</emphasis></para>
|
---|
35 |
|
---|
36 | <para>The <command>useradd</command> program uses a collection of
|
---|
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
|
---|
39 | defaults. You can see the default values by running
|
---|
40 | <command>/usr/sbin/useradd -D</command>.</para>
|
---|
41 |
|
---|
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>
|
---|
45 |
|
---|
46 | <screen># Begin /etc/default/useradd
|
---|
47 |
|
---|
48 | GROUP=100
|
---|
49 | HOME=/home
|
---|
50 | INACTIVE=-1
|
---|
51 | EXPIRE=
|
---|
52 | SHELL=
|
---|
53 | SKEL=/etc/skel
|
---|
54 |
|
---|
55 | # End /etc/default/useradd</screen>
|
---|
56 |
|
---|
57 | <para>The only thing missing from the file is a default shell. Add that
|
---|
58 | by running:</para>
|
---|
59 |
|
---|
60 | <screen><userinput><command>/usr/sbin/useradd -D -s/bin/bash</command></userinput></screen>
|
---|
61 |
|
---|
62 | <para>This will set the <envar>SHELL</envar>= line to
|
---|
63 | <envar>SHELL</envar>=/bin/bash.</para>
|
---|
64 |
|
---|
65 | <para><command>Useradd</command> has many parameters that
|
---|
66 | can be set in the <filename>/etc/default/useradd</filename> file.</para>
|
---|
67 |
|
---|
68 | <para>For more information see <command>man useradd</command>.</para>
|
---|
69 |
|
---|
70 | <para><emphasis>/etc/skel</emphasis></para>
|
---|
71 |
|
---|
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>
|
---|
76 |
|
---|
77 | <para>The mode of any files from this part of the book that you put in
|
---|
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
|
---|
81 | make them unreadable by "group" and "other".</para>
|
---|
82 |
|
---|
83 | <para>You can also put other files in
|
---|
84 | <filename class="directory">/etc/skel</filename> and
|
---|
85 | different permissions may be needed for them.</para>
|
---|
86 |
|
---|
87 | <para>Decide which initialization files should be provided in every (or most)
|
---|
88 | new user's home directory. The decisions you make will affect what you
|
---|
89 | do in the next two sections, <xref linkend="postlfs-config-profile"/> and
|
---|
90 | <xref linkend="postlfs-config-vimrc"/>. Some or all of those files will be
|
---|
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
|
---|
94 | <filename class="directory">/etc/skel</filename> include
|
---|
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
|
---|
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
|
---|
113 | of any other user already in the system.</para>
|
---|
114 |
|
---|
115 | <para><emphasis>When Adding a User</emphasis></para>
|
---|
116 |
|
---|
117 | <para>When adding a new user with <command>useradd</command>, use
|
---|
118 | the <option>-m</option> parameter, which tells
|
---|
119 | <command>useradd</command> to create the user's home directory and
|
---|
120 | copy files from <filename class="directory">/etc/skel</filename> (can be
|
---|
121 | overridden) to the new user's home directory. For example:</para>
|
---|
122 |
|
---|
123 | <screen><command>useradd -m jwrober</command></screen>
|
---|
124 |
|
---|
125 | </sect1>
|
---|