[Techtalk] In Search Of A Script to Change Attributes Of Files

John Clarke johnc+linuxchix at kirriwa.net
Mon Dec 1 17:28:03 EST 2003


On Sun, Nov 30, 2003 at 08:24:00PM -0800, Cynthia Kiser wrote:

> I generally don't want the same permissions for files as directories
> so I often do something like the following to change permissions only
> on the files: 
> 
> find . -type f -print | xargs chmod 664 {} \;
> 
> That will start from the current directory and change all of the files
> to have permissions of rw-rw-r--. 

If you want to do something similar, but keep execute permissions on
those files which already have it, you can use:

    chmod -R o=rX,ug=rwX .

The options mean:
    
    -R          recursive
    
    o           other users
        =rX     set permission to read, and, if the file is executable
                by anyone (i.e. any one of the three x bits set) or is
                a  directory, execute (r-- or r-x)
    
    ug          the file's user and group
        =rwX    set permission to read and write, and, if the file is
                executable by anyone or is a directory, execute (rw- or
                rwx).

The result is either 775 (executables and directories) or 664 (other
files).


Cheers,

John
-- 
whois !JC774-AU at whois.aunic.net
GPG key id: 0xD59C360F
http://kirriwa.net/john/


More information about the Techtalk mailing list