From owner-freebsd-questions Wed Jan 8 9:57: 0 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1258437B401 for ; Wed, 8 Jan 2003 09:56:59 -0800 (PST) Received: from shell.siscom.net (shell.siscom.net [209.251.2.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3AE0943EE6 for ; Wed, 8 Jan 2003 09:56:58 -0800 (PST) (envelope-from vogelke@shell.siscom.net) Received: from shell.siscom.net (vogelke@localhost [127.0.0.1]) by shell.siscom.net (8.12.3/8.12.3) with ESMTP id h08Hun7g062072; Wed, 8 Jan 2003 12:56:49 -0500 (EST) (envelope-from vogelke@shell.siscom.net) Received: (from vogelke@localhost) by shell.siscom.net (8.12.3/8.12.3/Submit) id h08HumLB062071; Wed, 8 Jan 2003 12:56:48 -0500 (EST) Delivered-To: outgoing@ss118-07u-558.region2.wpafb.af.mil Received: (qmail 29228 invoked by alias); 8 Jan 2003 12:56:07 -0500 Delivered-To: alias-outgoing-mauri@minut.ee Received: (qmail 29210 invoked by uid 583); 8 Jan 2003 12:56:06 -0500 Date: 8 Jan 2003 12:56:06 -0500 Message-ID: <20030108175606.29209.qmail@kev.wpafb.af.mil> From: "Karl Vogel" To: mauri@minut.ee Cc: questions@freebsd.org In-reply-to: <6FDBFE65-2235-11D7-8967-0003931E3224@minut.ee> (message from Lauri Laupmaa on Tue, 7 Jan 2003 13:44:53 +0200) Subject: Re: creating user dirs Organization: Sumaria Systems Inc. X-Disclaimer: I don't speak for the USAF or Sumaria. X-PGP-ID: 1024/D558F237 1999/04/06 Karl Vogel X-PGP-Fingerprint: 8DF5 1D90 18EC A9EF 9EA6 4611 35F4 BC78 D558 F237 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >> On Tue, 7 Jan 2003 13:44:53 +0200, >> Lauri Laupmaa 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