Migrating Users to a New Server
Nivethan
Posted on October 26, 2022
We can use awk to filter the user files, we are splitting on ':' and checking the 3rd field, the user id. We don't want to bring over the system users which are usually at the top. I chose 200 based on my experience at work.
awk -F: '($3>=200) && ($3!=65534)' /etc/passwd > passwd.bk
awk -F: '($3>=200) && ($3!=65534)' /etc/group > group.bk
awk -F: '($3>=200) && ($3!=65534) {print $1}' /etc/passwd | tee โ |egrep -f โ /etc/shadow > shadow.bk
/bin/cp /etc/gshadow gshadow.bk
The below commands will be run on the new machine once the backup files have been moved over.
cat passwd.bk >> /etc/passwd
cat group.bk >> /etc/group
cat shadow.bk >> /etc/shadow
/bin/cp gshadow.bk /etc/gshadow
Now we should be able to login with an existing user to make sure everything is working.
๐ ๐ช ๐
๐ฉ
Nivethan
Posted on October 26, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
undefined Anytime i install linux on a new machine or start fresh, this is where i will regain all of my cli tools.
November 28, 2024
cloud Cloud Monitoring and Logging: Key Tools and Practices for Ensuring Cloud Reliability
November 29, 2024
operatingsystem Understanding the Core Components of an Operating System and How They Work
November 29, 2024