Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to change the ownership and permissions of some files (and directories) in the current directory. I tried this:

chown username:groupname .

...expecting that it would affect all the files in the current directory, but instead only affected the directory that I am in (which is the opposite of what I want to do). I want to change it on all the files without affecting the current directory that I am in.

How can I chown and chmod all files in current directory?

share|improve this question
    
man chown and man chmod easily answer your question. –  Shi Aug 15 '12 at 21:08
1  
@Shi I think it's a fair question. Reading that man page wouldn't help. Globbing is not part of chmod. It is builtin to the shell. Also reading documentation on globbing sucks the life out of you (I spent way to much time figuring out all the zsh's features). –  djf Aug 15 '12 at 21:27
1  
@djf: chown -R user:group . –  Shi Aug 16 '12 at 20:05
add comment

2 Answers

up vote 11 down vote accepted

You want to use chown username:groupname *, and let the shell expand the * to the contents of the current directory. This will change permissions for all files/folders in the current directory, but not the contents of the folders.

You could also do chown -R username:groupname ., which would change the permissions on the current directory, and then recurse down inside of it and all subfolders to change the permissions.

chown -R username:groupname * will change the permissions on all the files and folders recursively, while leaving the current directory itself alone. This style and the first style are what I find myself using most often.

share|improve this answer
    
Ah, the asterisk. Thanks! –  Andrew Aug 15 '12 at 20:55
1  
@Andrew Be on your guard though, he can be both friend and foe to the weary or unprepared. –  Darth Android Aug 15 '12 at 21:07
add comment

I think you want this:

chown username:groupname *

If you also want to recursively change subdirectories, you'll need the -R (-r is deprecated) switch:

chown -R username:groupname *

share|improve this answer
add comment

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.