linux 用户迁移

 

1.账号和密码复制出来

awk -F: '($3>=500) && ($3!=65534)' /etc/passwd > passwd.txt 
awk -F: '($3>=500) && ($3!=65534)' /etc/group > group.txt
awk -F: '($3>=500) && ($3!=65534) {print $1}' /etc/passwd|tee -|egrep -f - /etc/shadow > shadow.txt
 
2.cp到新的机器上
scp IP:/root/*.txt .
 
3.追加到新的机器
 # cp /etc/passwd /backup/passwd-backup.txt  # cat /backup/passwd.txt >> /etc/passwd  # cp /etc/group /backup/group-backup.txt  # cat /backup/group.txt >> /etc/group  # cp /etc/shadow /backup/shadow-backup.txt      # cat /backup/shadow.txt >> /etc/shadow 
 
  

您可以选择一种方式赞助本站