Skip to main content

Posts

Showing posts from December 12, 2010

Changing File and Directory Permission en masse.

Running msec on one of my Mageia Linux machines turned up a number of world-writable files. These are potential security problems, especially on a machine that faces the Internet. The obvious solution was to use chmod to remove any world writable permissions. But there's the problem. The chmod command has a recursive directive, -R , that would work except that it would change permissions on the directories as well. After all in *NIX, all directories are files. Thanks to my friends at TWUUG , I discovered that the find command, used with its -exec directive could accomplish what I wanted. find /xxx -type f -exec chmod o=-w {} + ; Breaking this down: find - the find command itself. Depending on what files you are modifying, you may need to be root. /xxx - the path to where the files are located. -type f - this tells find to look for files; type d would tell it to look for directories. -exec - this directive tells find to execute the command that follows, in