Changing multiple permissions with one single command

command linelinuxpermissions

I have a directory say foo with permission rw-r----x. I want to change the permission to r-xr--r-x. I can do it like chmod u-w foo, chmod u+x foo, chmod o+r foo. I was wondering if there is a way to combine these three commands into one without using octal numbers.

Best Answer

You can just list with commas.

$ ls -l file
-rw-r----x 1 tomasz tomasz 0 Aug 12 22:24 file
$ chmod u-w,u+x,o+r file
$ ls -l file
-r-xr--r-x 1 tomasz tomasz 0 Aug 12 22:24 file

You can also use the = syntax.

$ chmod u=rw,g=x,o=rwx file 
$ ls -l file 
-rw---xrwx 1 tomasz tomasz 0 Aug 12 22:24 file
Related Question