Corrupted Linux/home folder, using Shell to quickly recreate

Source: Internet
Author: User

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:

    1. First create the desired group (vi/etc/group);

    2. Synchronization of/etc/group with/etc/gshadow (GRPCONV);

    3. Create the individual attributes of the account (VI/ETC/PASSWD);

    4. Synchronization of/etc/passwd with/etc/shadow (PWCONV);

    5. Create the password for the account (passwd accountname);

    6. Create User home directory (cp-a/etc/skel/home/accountname);

    7. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.