chown recursively changed permissions
By using {.,}*
, you included both ./
and ../
. Along with the -R
option, your chown
call was about to browse your entire filesystem (and others, possibly mounted), going through ../
. With other commands, this little mistake can be quite deadly, but believe me, you're not the first, and you won't be the last...
Since this operation is quite heavy, your chown
call hanged a while, as it had a lot of files to process. I'd suggest you go back to the directory where you made the call, and go back progressively to /
to see what changes were made. You might be able to apply a quick fix doing:
chown root:root /* # Set ownership to root for all directories in /.
chown you:yourgroup /home/you -R # Take your home back.
On Ubuntu, the /home
directory is given to the first (admin/sudo) user registered on the system. If you're the only user, you might want to do:
chown you:yourgroup /home -R
However, a simple chmod 755
on /home
is enough, even if it belongs to root.
Having a quick look directly at /
(including the root permissions themselves, ls -ld /
) would also be a nice place to start. I suggest you make sure that /
belongs to root, with a 755 permissions set.
If you used chown
to set a very specific ownership (a user other than you or root, a rare group, ...), you may want to use find
to look for chown
-ed files.
find / -user {username}
find / -group {groupname}
Unfortunately, there is no such thing as undo
for what your did. Linux doesn't naturally keep tracks of these "casual" operations.
For more information on what you were trying to achieve, have a look at this SuperUser question.
Related videos on Youtube
![nicoX](https://i.stack.imgur.com/xlRT6.jpg?s=256&g=1)
nicoX
Updated on September 18, 2022Comments
-
nicoX almost 2 years
I ran the chown command in a directory:
chown -R user:user {.,}*
The
{.,}*
is used withmv
andcp
to include both hidden and listed files. Now this command went through and changed those two files in my directory, but I had to break it to stop since it went on. Now I'm afraid it has gone and changed the permissions on other files and folders, since it didn't terminate.-
bain over 8 yearsPossible duplicate of What if I accidentally run command "chmod -R" on system directories (/, /etc, ...)
-
-
nicoX almost 10 yearsMy root directory seems to be good. It's owned by root.
-
John WH Smith almost 10 yearsYou must have killed
chown
on time then, but keep checking, going from the directory you executedchown
in, to the root. -
nicoX almost 10 yearsWas the problem here that I used the -R flag? And how can you change owner in one command for both hidden and listed files.
-
John WH Smith almost 10 yearsSee the link I added at the end of my answer. The
-R
was the problem, since you went recursively through..
as well, which eventually led you to altering the entire file tree from/deep/directory/where/you/chowned
to/
.