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