Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Mar 2017 19:57:58 +0100
From:      Polytropon <freebsd@edvax.de>
To:        ASV <asv@inhio.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: /etc/skel doesn't work?!
Message-ID:  <20170306195758.17d83f1d.freebsd@edvax.de>
In-Reply-To: <1488813922.11457.12.camel@inhio.net>
References:  <1488813922.11457.12.camel@inhio.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 06 Mar 2017 12:25:22 -0300, ASV wrote:
> Hello there,
> I haven't use this standard functionality for ages but yesterday I
> suddenly needed and then I've tried ... and failed.
> Further reading led me to add files that I want to be added on any new
> user home dir in /usr/share/skel/dot(filename).
>=20
> For example: to make my customised .zshrc copied on any new user home
> dir I'd just copy the .zshrc file in question to
> /usr/share/skel/dot.zshrc and it will be copied with the proper rights
> without the prepending "dot".
> And that works!

At the "top level", a real dot needs to be escaped with "dot.",
both for files and directories. Within directories, files can
be named "as is".

A little sidenote:

If you want to make users participate in the use of a customized
C shell configuration, you can use the global /etc/csh.cshrc and
leave the user's .cshrc (dot.cshrc in the skel/ directory) empty
for individual overrides. Advantage: When you improve /etc/csh.cshrc,
all users will immediately have that improvement, too.



> Nonetheless, according to my understanding, any file placed into
> /etc/skel should end up into the newly created user home directory but
> it does NOT.
> Doesn't matter how the file is named.

As I said, there is a specific naming convention that applies both
to /usr/share/skel and /etc/skel content. You can make the adduser
program use /etc/skel instead of /usr/share/skel in case you don't
want to "pollute" that directory. :-)

You can find details in "man adduser" and "man pw", which I'd like
to quote from the -m option:

	This option instructs pw to attempt to create the user's
	home directory.  While primarily useful when adding a new
	account with useradd, this may also be of use when moving
	an existing user's home directory elsewhere on the file
	system.  The new home directory is populated with the con-
	tents of the skeleton directory, which typically contains a
	set of shell configuration files that the user may person-
	alize to taste.  Files in this directory are usually named
	dot.<config> where the dot prefix will be stripped.  When
	-m is used on an account with usermod, existing configura-
	tion files in the user's home directory are not overwritten
	from the skeleton files.

This section clearly states the convention of the "dot" prefix.



> Looks like a bug to me.

No, it doesn't. :-)



> My machine:=A0FreeBSD 11.0-RELEASE-p2 (amd64)
> Command used:=A0pw useradd <username> -m

Correct.



> P.S. would be interesting to know why "dot" is required to be prepended
> in files added in /usr/share/skel

Convention, because the copying routine uses this replacement
for "real" files (source/dot.* -> target/.*) whereas it ignores
hidden file (source/.*); I don't know why, but you can have
hidden files in the skel/ directories which are ignored at
its top level.



--=20
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170306195758.17d83f1d.freebsd>