Super User is a question and answer site for computer enthusiasts and power users. 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 would like to change the owner of a directory and all files and directories below it to the user nobody.

I have a /parent_dir with owner root. I want to change the owner to nobody (system user) recursively.

share|improve this question

migrated from Feb 23 '11 at 0:58

This question came from our site for professional and enthusiast programmers.

Like this:

sudo chown -R nobody /parent_dir
share|improve this answer

By using the -R command line parameter of chown.

chown -R nobody /parent_dir
share|improve this answer

Just as an alternative to the other answers:

sudo find /parent_dir -exec chown nobody {} \;

if you only want to change files you could use -type f or -type d for directories. comes in handy, when you want to chmod stuff.

share|improve this answer
another thing you can do here is restrict it to only change files from one particular owner to another. If only a few files are root owned that can save a lot of metadata writes. – Bron Gondwana Jul 25 '12 at 11:57
Thanks for the answer, indeed this one was the only one working for me! – Arturas M Jul 30 '14 at 10:00

You may change the owner of the directory recursively using the following command. -R stands for recursive.

chown -R ownername foldername

You can also change the owner and group of the directory recursively using the following command.

chown -R ownername:groupname foldername

For more details refer this.

share|improve this answer

You must log in to answer this question.