fsck

David King dking at ketralnis.com
Wed Sep 27 15:31:20 PDT 2006


>> And now for something completely different.... If I can't get the / 
>> usr
>> partition to work is there any way to recreate the user  
>> directories from
>> the password file? The contents will be lost but nobody uses their  
>> folder
>> anyway, I just need all the /usr/home folders created... I could  
>> write a
>> script, but I thought I'd check first to see if something already  
>> exists.......
> That's trivial.  In /bin/sh syntax:
> # cd /home
> # awk -F: '$3>999{print $1}' /etc/passwd | xargs mkdir
> # for i in *; do chown $i:$i $i; done

It might help to copy the stuff out of /usr/share/skel, too, like  
this (untested):

cd /home
for user in `awk -F: '$3>999{print $1}' /etc/passwd`; do
	cp -r /usr/share/skel ./$user

	for dotfile in $user/dot.*; do
		mv $dotfile `echo $dotfile | sed 's#/dot\.#.#'`
	done

	chown -R $user:$user $user
done

Take a look at /usr/sbin/adduser to see how it does it

> That will create home directories for all users whose UID
> is greater than 999.
>
> Best regards
>    Oliver
>
>
> -- 
> Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
> Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
> Any opinions expressed in this message may be personal to the author
> and may not necessarily reflect the opinions of secnetix in any way.
>
> "C++ is the only current language making COBOL look good."
>         -- Bertrand Meyer
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers- 
> unsubscribe at freebsd.org"

--
David King
Computer Programmer
Ketralnis Systems




More information about the freebsd-hackers mailing list