On Mon, 2003-06-09 at 08:39, Alan Wilter Sousa da Silva wrote:
> Hi List!
>
> I'll set up a new server (MDK 8.0 -> 9.1) and I would like to
> keep the same users, but without cloning or copying /home folders. I
> know I can copy /etc/passwd file. But I don't know how to regenerate
> automatically new /home/users folders (from /etc/skel ?) without using
> userdrake (or similar). I would like to keep gid and uid numbers.
>
> Is there a way, how-to, or tip to do it.
>
> Many thanks in advance for any help.
You could do something like this:
#!/bin/bash
for item in `cat /etc/passwd`; do
USERNAME=`echo $item | cut -d: -f1`
USERID=`echo $item | cut -d: -f3`
GROUPID=`echo $item | cut -d: -f4`
COMMENT=`echo $item | cut -d: -f5`
USERDIR=`echo $item | cut -d: -f6`
USERSHL=`echo $item | cut -d: -f7`
echo useradd -u ${USERID} -g ${GROUPID} -c ${COMMENT} \
-d ${USERDIR} -s ${USERSHL} ${USERNAME}
done
Remove the "echo" to actually run the command.
Let me know if you'd prefer an awk version...
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com