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 have a tar archive containing two owners, 1000 and 0 :

$ tar tfvz archive.tgz
drwxr-xr-x 1000/1000         main/
drwxr-xr-x 0/0               main/root_dir/
drwxr-xr-x 0/0               main/root_dir/home/
-rw-r--r-- 1000/1000         main/root_dir/home/file

Is there a simple way to change ownership only on directories/files with owner 1000 ? Those with owner 0 must stay unchanged.

I didn't find any options in tar or find that select a specific owner, for example tar --no-same-owner change all owners, not only owner 1000 (I extract archive with sudo tar xfz archive.tgz to allow creation of root (0) directories/files).

share|improve this question
up vote 3 down vote accepted

You can use find's uid switch to do this after you have extracted the files

find /path/to/files -uid 1000 -exec chown newuid:newgid {} +
share|improve this answer

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.