Date: Fri, 24 Sep 2004 15:51:38 -0000 From: Karl Vogel <vogelke@pobox.com> To: dwbear75@gmail.com Cc: questions@FreeBSD.ORG Subject: Re: creating user dirs Message-ID: <20030108175606.29209.qmail@kev.wpafb.af.mil> In-Reply-To: <6FDBFE65-2235-11D7-8967-0003931E3224@minut.ee>
next in thread | previous in thread | raw e-mail | index | archive | help
>> On Tue, 7 Jan 2003 13:44:53 +0200,
>> Lauri Laupmaa <mauri@minut.ee> said:
L> Is there a simple solution for creating all user directories under
L> /home? So, I have clean /home filesystem and hundreds of users in
L> /etc/*passwd. Hopefully there is some simple command or script :)
Create a subset of the passwd file with the user, group, and home
directory only:
# cut -f1,4,6 -d: /etc/passwd | grep /home/ | sed -e 's/:/ /g' > /tmp/pw
Create the directory tree. You need the '-p' flag in mkdir if you
have multiple levels of directories under /home:
# awk '{print "mkdir -p", $3}' /tmp/pw | sh
Next, set permissions. Use 750 instead of 755 if you don't want
world read access to user's home directories:
# awk '{print "chmod 755", $3}' /tmp/pw | sh
If you want to populate the home directories with some default dot files
(.profile, etc) you can do something like
# cd /etc/skel
# awk '{print "find . -print | cpio -pdum", $3}' /tmp/pw
Finally, set ownerships. This assumes you want the user's home
directory and files owned by the user and the default user's group:
# awk '{print "chown -R", $1"."$2, $3}' /tmp/pw | sh
# rm /tmp/pw
--
Karl Vogel I don't speak for the USAF or my company
vogelke@pobox.com http://www.pobox.com/~vogelke
If all the veins in your body were laid end to end, you'd be dead.
--unknown
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?20030108175606.29209.qmail>
