Archive for February, 2010
06th February
2010
I recently had to create a number of home directories from the user accounts in the /etc/passwd file because Webmin didn't create them when the user was created. Don't ask me why. Webmin is a mystery and only does things it feels like doing at the time it does them. But I digress..
The first thing I did was to create file with all users that have directories.
cat /etc/passwd | sed 's/:/ /g' | awk '($5 ~ /\//) { print $1 " " $5}' > file.txt
Edit the file you created and remove things like the postfix directory and other non-user account directories.
Next, run the command to create all of the home directories and then change their ownership to the user.
while read line; do mydir=`echo $line |awk '{print $2}'`; myuid=`echo $line| awk '{print $1}'`; mkdir $mydir 2>/dev/null; chown $myuid:$myuid $mydir; done < file.txt
0 Comments