checking file's permissions and change them

Hi all,

I am very new to UNIX and Shell scripting, I need to run a script to check for file's and directoires permissions and change the permissions if necessary.

I appreciate your help..

Thanks

K-ONE,

A simple find can do it. For example, if you wanted to remove the write bit for "others":

find . -type f -perm -o+w -exec chmod o-w {} \;

Cheers,

Keith

Are you checking for particular permissions? You can use the find command for that:

find / -perm -xxxx -exec ls -l {} \; > /tmp/somefile

This will just list files with a particular permission and store the output in /tmp/somefile. If you want to act on a particular type of permissions, such as removing world write from files and/or directories, you could go about it like this:

find / -perm -0002 -exec chmod o-w {} \;

As always, for detailed explainations, check man pages of ls, chmod, find. These will help.

thanks for your reply, is there any other way of doing this if you don't want to use the find command.

please advise

Is this a home work problem? Sounds like that now...

I agree. Why wouldn't you want to use find?

I'm pretty sure it is a homework problem and also a duplicate of this thread

I agree. Thread closed.