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