Wednesday, August 20, 2008

Common error while changing ownership of dot(.) or hidden files

Incorrect command:
chown .* directory_name
chown *.* directory_name

The problem is that every directory on a unix-type file system contains two special directories:
"." refers to the directory itself
".." refers to the parent directory

Thus, files in one of the directories we were trying to chown (change ownership) was the directory itself, and then the command recursively chown everything from the directory above it in the file tree, all the was upto root directory (/).

Correct command should have been:
chown .[a-zA-Z0-9]* directory_name

No comments: