Following files/dirs are required for traditional Linux user management:
* /etc/passwd - contains various pieces of information for each user account
* /etc/passwd - contains various pieces of information for each user account
* /etc/shadow - contains the encrypted password information for user's accounts and optional the password aging information.
* /etc/group - defines the groups to which users belong
* /etc/group - defines the groups to which users belong
* /etc/gshadow - group shadow file (contains the encrypted password for group)
* /var/spool/mail - Generally user emails are stored here.
* /home - All Users data is stored here.
Pre
- mkdir /move
Backup user account
- We only want to keep user account except account used by system, so we only backup account with UID LIMIT >= 500.
Backup Groups
awk -v LIMIT=500 -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /move/group
Backup User & Group password
- awk -v LIMIT=500 -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /move/shadow
- cp /etc/gshadow /move/gshadow
Backup /home & /var/spool/mail
- tar -zcvpf /move/home.tar.gz /home
- tar -zcvpf /move/mail.tar.gz /var/spool/mail
No comments:
Post a Comment