Re: creating user dirs
On Tue, 7 Jan 2003 13:44:53 +0200, Lauri Laupmaa [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: creating user dirs
Karl Vogel wrote: On Tue, 7 Jan 2003 13:44:53 +0200, Lauri Laupmaa [EMAIL PROTECTED] 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 ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: creating user dirs
On Tue, 7 Jan 2003 13:44:53 +0200, Lauri Laupmaa [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
creating user dirs
Hi Is there a simple solution for creating all user directories under /home ? So, I have clean /home filesystem and hundreds of users in /etc/*passwd Hopefully there is some simple command or script :) TIA L. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: creating user dirs
* Lauri Laupmaa [EMAIL PROTECTED] [20030107 19:47]: Hopefully there is some simple command or script :) mkdir `cat /etc/passwd | cut -d : -f 6` this assumes that the home_dir field of users is correctly set qvb -- pica To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: creating user dirs
In [EMAIL PROTECTED], Lauri Laupmaa [EMAIL PROTECTED] typed: Hi Is there a simple solution for creating all user directories under /home ? So, I have clean /home filesystem and hundreds of users in /etc/*passwd Hopefully there is some simple command or script :) You can get the list from /etc/password easily enough with awk. I'd do: USERS=$(awk -F: '$3 999 { print $1 }' | grep -v nobody) which assumes you follow the convention of new users being above 1000. Given that list, you can easily create the directories: cd /home for user in $(awk -F: '$3 999 { print $1 }' | grep -v nobody) do mkdir $user # Copy whatever else you want into place, say /etc/skel/.* chown -R $user $user done mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/consulting.html Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message