From owner-freebsd-questions Fri Apr 5 6:11:25 2002 Delivered-To: freebsd-questions@freebsd.org Received: from dns.perimeter.co.za (dns.perimeter.co.za [196.25.164.254]) by hub.freebsd.org (Postfix) with ESMTP id CDBF237B417 for ; Fri, 5 Apr 2002 06:11:15 -0800 (PST) Received: from PATRICK (loopback.mipjhb [209.212.102.245] (may be forged)) by dns.perimeter.co.za (8.11.1/8.11.1) with SMTP id g35EB8505000; Fri, 5 Apr 2002 16:11:09 +0200 (SAST) (envelope-from bsd@perimeter.co.za) Message-ID: <014f01c1dcab$78a608b0$b50d030a@PATRICK> From: "Patrick O'Reilly" To: , References: <1018013904.3cada8d0cf171@mail.broadpark.no> Subject: Re: Redistributing adduser's dotfiles to users Date: Fri, 5 Apr 2002 16:09:15 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 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 From: > 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