How to get "drwx --- rx +" permission using CHMOD? - bash script

I am having a problem moving some files on my network and seem to be caused by file permissions.

I currently have folders with these rights drwxrwxrwx. I need to run a bash script that will change permissions to drwx --- rx +

ACL should be there.

I do not quite understand how I can achieve the same permissions using the CHMOD commands. I have tried so far:

chmod -R ugo = rx "file"

But that seems to be changing to dr-xr-xr-x, which is not enough ...

So the question is, what command should I execute to achieve drwx --- rx + ??

Thanks in advance.

PS. This command should be run on MACOSX Maveriks, so the "setfacl" command will not help.

+6
source share
1 answer

The drwx---r-x+ permissions are broken as follows:

  • d is a directory, of course.
  • rwx means that it is readable, writable, and access the u service. These three bits can be represented by the octal number 7 .
  • --- means that the three bits mentioned above are NOT set for the rome g assigned to the directory. The bits are not set, so the octal number is 0 .
  • rx means that users who do not coincide with the first two categories, that is, all the others, or o ther "- can read and access the contents of the directory, but cannot write. The bits here are in the column and column fours, so the octal number, which this permission represents is 5 .
  • + indicates that there is an "extended security information" associated with this directory that is not shown in the standard ls format "long format". Access Control List, for example.

To set the basic permissions of this directory, you can use the octal short hand:

 $ chmod 705 directoryname 

or you can use a symbolic representation:

 $ chmod u+rwx,g-rwx,o+rx-w directoryname 

Obviously shortened ... shorter.

For the extended security information indicated by + , you will need to find out what is configured for its replication. The ls has the -e option to show advanced security options.

To actually set the ACL from the command line, you must use the chmod'a =a , -a and +a options. Documentation of this is available on OSX from man chmod . On this page:

  Examples # ls -le -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1 owner: juser 1: admin allow delete # chmod =a# 1 "admin allow write,chown" # ls -le -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1 owner: juser 1: admin allow write,chown 
+15
source

Source: https://habr.com/ru/post/983841/


All Articles