• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

add user accounts

Hello experts,

Recently I reinstaleed whole server frm debian 3.0 woody to Ubuntu Linux. I kept all conf files from the previous system including /etc/passwd and /etc/shadow /etc/samba/smbpasswd. Before I start creating all account on new system manula I would like to aske if there is some way how to automatize this process. All users home folders are already mounted as different partion. I'm thinking about create script which will read my old passwd file and add new users to new system. It is something around 70 names. Is there a chance to automatize this somehow?


4 Solutions
did u try using the old files? I would.

ok, I think you would like to make a test first.

make a copy of a line from /etc/passwd and  /etc/shadow into the respective new files, and try to login as the user. chances are that it will work, the same for the Samba password file.
In most case, the old files should work, you need to remember to modify the home dir in /etc/passwd file if they are differ from the old one, don't forget the /etc/group file.

It is possible to use script to create all the new users for you, you can create a text file
with loginname passwd home_dir shell etc, and use the script to read the input file and create
the users.

Have a look at http:Q_21112403.html  to get some idea how to write the script.
Since you still have the home directories the easy way to add the users is to merge the lines for those users from the old files (passwd, shadow, group, & gshadow) into the coresponding files on the new system. Since you've changed versions I would not simply copy the old files into place since system accounts may be different.
here's a little script that may help

assuming that  pevious files are in the same dir and you added the extension .old_deb to them

for f in passwd groups shadow
# copy the sytem installed files in case thing go bad
cp $f $f.orig
cat $f.old_deb >> $f
cat $f  | sort  | uniq > tmp
mv tmp $f

you can then scan the file with vi and remove any dodgy dups where for example the shell path is wrong.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now