Control which files are copied to a new user's home directory during account creation
Reviewer: name contact BSD flavour
Reviewer: name contact BSD flavour
Concept
BSD systems use a "skel" directory containing files which are copied over to a user's home directory when a user account is made. Be aware of the location of the skel directory on each BSD, as well as how to override the copying of its contents during account creation.
Introduction
A number of files control a user's environment; generally these are "sourced" at login to set variables, aliases, shell prompts and other options, but others may hold information used in processing mail or making remote connections. Generally these files (.login, .cshrc, .shrc, .rhosts, .mailrc
and maybe some others) are referred to as "dotfiles" (for somewhat obvious reasons - remember also that files that begin with "." are not generally shown by ls
).
As a system administrator, you may wish for your users to all have similar environments set up when they log in --- perhaps colorized file listings, customized mail or program aliases, their own executable path, and so on. Rather than teaching all your users to set up their own dotfiles/environment, or (perhaps worse) editing all the users' dotfiles yourself, BSD systems have a "skeleton directory" where master copies of the dotfiles are stored. By editing the master dotfiles in this "skel" directory, you can do the editing once and then have these files copied to a new user's $HOME during the adduser/useradd
process.
Finding the Dotfiles!
The names and locations of the "dotfiles" vary somewhat in each branch of the BSD's. For FreeBSD and DragonFly, look in /usr/share/skel:
FreeBSD$ ls /usr/share/skel
dot.cshrc dot.login_conf dot.mailrc dot.rhosts
dot.login dot.mail_aliases dot.profile dot.shrc
NetBSD and OpenBSD store their "master dotfiles" under /etc/skel
.
At one time, OpenBSD stored "dotfiles" in /etc/dotfiles. The fact that their dotfiles were/are really dotfiles confused a few people (collected on the Internet, 2007, an archived discussion from some years before):
OpenBSD$ ls /etc/dotfiles
OpenBSD$
Try using "ls -a":
OpenBSD$ ls -a /etc/dotfiles
. .. .cshrc .login .mailrc .profile .rhosts
Examples
Practice Exercises
More information
pw(8), adduser.conf(5), useradd(8) or adduser(8), and usermgmt.conf(5)