Problem Description:
LAN built Hadoop Environment, node/home is mounted on a separate disk, a power outage causes several node/home file system corruption, unable to recover, only after formatting and re-mount home/home, and then use the script to quickly recover many users of Hadoop.
SOURCE citation: "Bird's private cuisine" Manually create a user process:
First create the desired group (vi/etc/group);
Synchronization of/etc/group with/etc/gshadow (GRPCONV);
Create the individual attributes of the account (VI/ETC/PASSWD);
Synchronization of/etc/passwd with/etc/shadow (PWCONV);
Create the password for the account (passwd accountname);
Create User home directory (cp-a/etc/skel/home/accountname);
Change the properties of the user home directory (chown-r accountname.group/home/accountname).
Because only the/home file is corrupted, only the 6th and 7th steps are required, the script is as follows:
#!/bin/bash
For user in ' cat/etc/passwd|tail-20 | Awk-f: ' {print '} ';d o
mkdir-pv/home/$user
Cp-a/etc/skel/.bash_profile/home/$user
Cp-a/etc/skel/.bash_logout/home/$user
Cp-a/etc/skel/.bashrc/home/$user
Chown-r $user: $user/home/$user
Done
~
~
Corrupted Linux/home folder, using Shell to quickly recreate