Batch change permissions for folders and files

If you ever need to change permissions for a bunch of folder and/or files without a GUI, you can utilize find and xargs to achieve that in the shell in a flash:

Shell

Basically what we are doing here is using find to find every directory or file, depending on the type. The option xtype, followed by d or f, helps us limit the (recursive) search to directories and files respectively. xtype includes symbolic links into the results, while type would not. the resulting directory/file names are then piped into xargs, which applies the command it is followed by (here: chmod 755 and chmod 644) to the list it receives from the pipe.

Leave a Reply

Your email address will not be published. Required fields are marked *