Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Apr 2002 16:09:15 +0200
From:      "Patrick O'Reilly" <bsd@perimeter.co.za>
To:        <johann@broadpark.no>, <questions@FreeBSD.ORG>
Subject:   Re: Redistributing adduser's dotfiles to users
Message-ID:  <014f01c1dcab$78a608b0$b50d030a@PATRICK>
References:  <1018013904.3cada8d0cf171@mail.broadpark.no>

next in thread | previous in thread | raw e-mail | index | archive | help
From: <johann@broadpark.no>


> Hi.
>
> What is the easiest way of redistributing the dotfiles adduser grabs
from
> /usr/share/skel to all the users on a system?
>

I don't know a utility for this job, but a little command-line scripting
should be quite easy:

# cat /etc/passwd | cut -d":" -f1 > /tmp/usr-list
# vi /tmp/usr-list    (remove any accounts that you don't want to
affect, like root?)
# cd /home
# for usr in `ls`
> do
> echo ${usr}
> for file in `ls /usr/share/skel`
> do
> newfile=`echo ${file} | cut -d"." -f2`
> cp /usr/share/skel/${file} ${usr}/.${newfile}
> done
> chown -R `grep "^${usr}" /etc/passwd | cut -d":" -f3,4` ${usr}
> done
patrick
jenny
stephan
andre
jack
amy
#

Notes:
1) the last few lines above show each user's name echoed as the script
runs.
2) this script will reset the file ownerships RECURSIVELY for EVERYTHING
in the user's home directory based on the userid and groupid in
/etc/passwd.  You might not want to do exactly that, so give it a little
thought.

To build your confidence, you could create a test account, damage it's
home directory's .files, and then fix it using this script with just
that test account's name in the /tmp/1 file.

If you need this often, just write it all into one script, and keep it
for posterity.

HTH,
Regards,
Patrick O'Reilly.
    ___        _            __
   / _ )__ __ (_)_ __ ___ _/ /____ __
  / __/ -_) _) /  ~  ) -_), ,-/ -_) _)
 /_/  \__/_//_/_/~/_/\__/ \__/\__/_/
    http://www.perimeter.co.za



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?014f01c1dcab$78a608b0$b50d030a>