34
15
Is it possible to find and chown all files that a specific user owns? I did a bunch of things as the wrong user and need to give the correct user ownership of the files.
Is there a recursive and conditional way I can chown a bunch of files and directories?
In case anyone else is looking for how to find files not owned by a certain user (user's files in a home directory that are not owned by that user), you can add '!' to the
-user other-user
section to find the opposite. For example,find . ! -user other-user
. – Jon – 2016-05-13T16:48:32.617Often the above is more useful when you add
-group old-group
. That way you can preserve group ownership (admin, staff, sillyothergroupname) – brianlmerritt – 2016-07-12T07:55:40.143ps - chown may require sudo – brianlmerritt – 2016-07-12T08:33:03.157
What I was looking for. But just to note that the options after the chown
new-user:new-user
should probably saynew-user:new-group
– Henesnarfel – 2014-02-14T18:09:17.4002I'm guessing the curly brackets should be in quotes to properly handle paths with spaces. So
find . -user old-user -exec chown new-user:new-group "{}" \;
– Dan Benamy – 2014-06-10T00:38:59.430