Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
First check if the user you want to give ownership exists. grep "username" /etc/passwd if the users exists you can run sudo chown -R username:username /home/username. What is the error you are getting ? – val0x00ff Feb 14 '13 at 12:54
I get this. I was just wondering if there was some way of doing it all at once instead of one by one – samdunne Feb 14 '13 at 12:58
With the answers below, if your chown command 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 '13 at 13:10
as a side note, tar is fairly reliable way of getting all types of files and permissions across to another location intact, especially if you are using the same uid/gids from passwd and group. You can dump in one step without an intermediate file, and even remotely if root ssh is available tar -cf - /home | ssh root@host "cd / && tar -xvf -" – Matt Feb 14 '13 at 16:23
up vote 2 down vote accepted

You can always change home directories one by one:

cd /home
for user in *; do chown $user.$user $user -R; done
share|improve this answer
Worked perfectly. Thank you :) – samdunne Feb 14 '13 at 13:15

Previous version, but with forks, all 'chown' processes will work parallel after starting.

cd /home
for user in *; do chown -R $user.$user $user&; done
share|improve this answer

getfacl -R ... | setfacl --restore may be useful.

Are the users configured on the new system? What does "to no avail" mean? Error message? Can you change any file's owner? chown user1 testfile

share|improve this answer
Yep, sorry I meant that command didn't do what I expected it to. I'm editing the question now – samdunne Feb 14 '13 at 12:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.