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.
For a little more secure approach I'd recommend creating a group for those 3 users and then chown'ing the directory by the group.
1. sudo groupadd mygroup
2. sudo usermod -aG {group-name} username
In your case it'd be
sudo usermod -aG mygroup plex ; sudo usermod -aG mygroup root ; sudo usermod -aG mygroup myuser
3. chown -Rf :mygroup /media
Best Answer
Remember that the command line is expanded (interpreted) by the shell before being executed
is interpreted first as :
note the
/myfolder/..
in your command linechown -R luca:luca /myfolder/..
is equivalent tochown -R luca:luca /
that makes the chown running "backwards"
Use
echo /myfolder/.*
when you use "*" to verify .