-1

I am using Linux (RHEL 7.5) and have a directory containing some files and directories that have 750 permissions (or lower), and some files and directories that have 777 permissions.

I wish to increase the permissions (recursively) for those files and directories that are at 750 (or below) to 755, but to leave those that have permissions 777 as they are.

How can I accomplish this selective "ratcheting up" of permissions?

0012
  • 142
  • 3
  • 9
  • According to `man` (you did read man, right?) you can use + to add bits and - to subtract bits. – Gem Taylor Nov 12 '18 at 20:08
  • Thanks for your reply. I did read man chmod, and I think you are referring to this section: "The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes them to be removed; and = causes them to be added and causes unmentioned bits to be removed except that a directory's unmentioned set user and group ID bits are not affected." I think I'm failing to understand something fundamental about chmod--can you please explain to me how the + and - can be used to solve my problem? – 0012 Nov 12 '18 at 20:15
  • 1
    You want to add the `r` and `x` permissions to others. If the permissions are already `777`, it won't change anything. If the permissions are `750` it will change to `755`. – Barmar Nov 12 '18 at 20:21
  • [so] is for programming questions, not questions about using or configuring Linux and its applications. [su] or [unix.se] would be better places for questions like this. – Barmar Nov 12 '18 at 20:21
  • 1
    So it should be `o+rx`. – Barmar Nov 12 '18 at 20:22

1 Answers1

1

You can add permissions using the + operator, so to make sure they are at least 755 you can do chmod -R u+rwx,go+rx /some/path - in other words, make sure the user has read, write and executable rights, and that group and other have read and execute.

l0b0
  • 55,365
  • 30
  • 138
  • 223