Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I ran the chown command in a directory:

chown -R user:user {.,}*

The {.,}* is used with mv and cp 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.

share|improve this question

1 Answer 1

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 / -user {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.

share|improve this answer
    
My root directory seems to be good. It's owned by root. –  nicoX Jul 24 at 15:47
    
You must have killed chown on time then, but keep checking, going from the directory you executed chown in, to the root. –  John WH Smith Jul 24 at 15:48
    
Was the problem here that I used the -R flag? And how can you change owner in one command for both hidden and listed files. –  nicoX Jul 24 at 15:56
1  
See 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 /. –  John WH Smith Jul 24 at 15:57

Your Answer

 
discard

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.