30 May 2004

chmod (distinguish between files and directories)

Posted by Jacob Emcken

I hate having execute bit set on files not supposed to be executable. But I have always found it a lot easier to set it to keep directories browseable when chmod’ing a directory recursive. Now I thrown a little bash line together to easily only chmod files or directories.

This only chmod’s files:

debian:~# find -type f  | xargs -i chmod 640 {}

This only chmod’s directories:

debian:~#find -name '*' -type d  | xargs -i chmod 750 {}

The -name ‘*’ makes sure that it is only sub directories is processed (and not the current directory).

1 Comment to chmod (distinguish between files and directories)

Per Marker Mortensen
June 16, 2004

One could use someting like

chmod ug+X instead

:)

notice the capital letter X.

Leave a comment