I recently migrated a server to another machine in our rack. They ownership/permissions didn't transfer when I moved /home from machine1 to /home on machine2 (both Ubuntu machines)
The user accounts successfully transfered and are all there.
I was wondering if there is a way to dynamically change all of /home to be owned by their username as currently everything is owned by root:root
I tried sudo chown -R $USERNAME: /home/$USERNAME to no avail
Any ideas?
Edit 1:
I can successfully change permissions through the use of chown -R someUser:someUser /home/someUser
My question is there a simple way to do this in bulk through the whole /home directory
Apologies for the confusion

grep "username" /etc/passwdif the users exists you can runsudo chown -R username:username /home/username. What is the error you are getting ? – val0x00ff Feb 14 at 12:54chowncommand has an ampersand after it, all of the chowns will run in parallel in the background. This may not be any faster than running them sequentially as the operation is most likely disk-bound anyway. – Ladadadada Feb 14 at 13:10tar -cf - /home | ssh root@host "cd / && tar -xvf -"– mindthemonkey Feb 14 at 16:23