creating user dirs

Chris racerx at makeworld.com
Fri Sep 24 09:17:26 PDT 2004


Karl Vogel wrote:
>>>On Tue, 7 Jan 2003 13:44:53 +0200, 
>>>Lauri Laupmaa <mauri at 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
> 

Someone better fix the system clock


More information about the freebsd-questions mailing list