Together, the /usr/sbin/useradd command and
/etc/skel directory (both are easy to
set up and use) provide a way to assure new users are added to your
LFS system with the same beginning settings for things such as the
PATH, keyboard processing and other
environmental variables. Using these two facilities makes it easier
to assure this initial state for each new user added to the system.
The /etc/skel directory holds copies of
various initialization and other files that may be copied to the new
user's home directory when the /usr/sbin/useradd program adds the
new user.
The useradd program
uses a collection of default values kept in /etc/default/useradd, if it exists. If this file
does not exist, then it uses some internal defaults. You can see the
default values by running /usr/sbin/useradd -D.
To change these values to something new, create a base /etc/default/useradd file as the root user with the same values as the output of
/usr/sbin/useradd -D.
Here is a sample:
# Begin /etc/default/useradd
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=
SKEL=/etc/skel
# End /etc/default/useradd
The only thing missing from the file is a default shell. Add that by
running the following command as the root user:
/usr/sbin/useradd -D -s/bin/bash
This will set the SHELL= line to
SHELL=/bin/bash.
useradd has many
parameters that can be set in the /etc/default/useradd file. For more information see
man useradd.
To get started, create an /etc/skel
directory and make sure it is writable only by the system
administrator, usually root. Creating
the directory as root is the best way
to go.
The mode of any files from this part of the book that you put in
/etc/skel should be writable only by
the owner. Also, since there is no telling what kind of sensitive
information a user may eventually place in their copy of these files,
you should make them unreadable by "group" and "other".
You can also put other files in /etc/skel and different permissions may be needed
for them.
Decide which initialization files should be provided in every (or
most) new user's home directory. The decisions you make will affect
what you do in the next two sections, The Bash Shell
Startup Files and The vimrc Files. Some or all
of those files will be useful for root, any already-existing users, and new users.
The files from those sections that you might want to place in
/etc/skel include .inputrc, .bash_profile, .bashrc, .bash_logout, .dircolors, and .vimrc. If you are unsure which of these should be
placed there, just continue to the following sections, read each
section and any references provided, and then make your decision.
You will run a slightly modified set of commands for files which are
placed in /etc/skel. Each section will
remind you of this. In brief, the book's commands have been written
for files not added to
/etc/skel and instead just sends the
results to the user's home directory. If the file is going to be in
/etc/skel, change the book's command(s)
to send output there instead and then just copy the file from
/etc/skel to the appropriate
directories, like /etc, ~ or the home directory of any other user already
in the system.
When adding a new user with useradd, use the -m parameter, which tells useradd to create the user's home
directory and copy files from /etc/skel
(can be overridden) to the new user's home directory. For example
(perform as the root user):
useradd -m <newuser>
Last updated on 2007-04-04 21:42:53 +0200