Using find, xargs, and chmod commands

chmod does not change the permissions to all directories in a single command line without affecting the permissions of files and vice versa. How can I do that?

You must combine: find, xargs and chmod, for example:

1. To change the permissions of the directories

Full access for the owner and group, 0 access for the rest, keep the file permissions

$ find /var/ftp -type d -print0 | xargs -0 chmod -v 770
2. To change the permissions of files

Full access for the owner, reading, writing for the group, 0 access for the rest, keep the permissions of directories

$ find /var/ftp -type f -print0 | xargs -0 chmod -v 760

Further reading

  • - man find
  • - man xargs
  • - man chmod
The tutorials here on LibreByte are provided under a free software licence. if you like my work you should consider:
Buy a Hosting/VPS or Dedicated Server at MCKHost

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.