0

Trying to repair/replace a system from a failed backup.

/etc is gone, trying to recover that, but in the meantime I need to work on a plan B.

/home remains with UID and GID and all of the important data (email). Approximately 300 users 600Gig containing dovecot/imap folders.

The problem is recreating the users:

Assuming worst case scenario, is there a way to mine the username, UID and GID from the /home directory and feed that into /etc/password /etc/group /etc/shadow files (setting the password to the username?)

  • 1
    Have you tried ls -l /home? – Michael Hampton Apr 13 '14 at 18:36
  • ls -aln gives me nice numeric uid and gid as well as the name. The trick for me is the correct use of awk to pull those data elements out then feed them back into adduser or useradd any suggestions on that? – user3033312 Apr 13 '14 at 22:10
  • Playing around I have come up with the following: ls -aln | awk '{print "useradd -s /bin/bash -u "$3 " -m -d /home/"$9 " -p $(openssl passwd -1 "$9"888) " $9}' If I pipe that output into a file, then run that file as a bash script. I think that will create my users, create their home directories, and set their passwords to their usernames+888 Naturally they'll be foreced to change their passwords on login Now, what am I missing? – user3033312 Apr 13 '14 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.