Posts Tagged ‘linux debian find xargs chmod’

Debian modifying permissions for files or directories

July 25th, 2008 No comments

Sometimes you want to change specific settings to either files or directories on your debian machine. To be able to do this I use the find command combined with the xargs command. Have a look at some possible commands:

find /share/ -type f -print0 | xargs -0 chmod 664
find /share/ -type d -print0 | xargs -0 chmod 775

The first line tries to find files only with -type f. And prints them to the stream with -print0 so xargs can process them with the -0 command. -print0 will put a NUL value between pathnames. This way paths that contain spaces can be parsed correctly by xargs.
I think it is pretty nifty and once again shows the power of the console!