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?
Best Answer
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.