Tengo una aplicación que se queja de los permisos de su directorio dentro de /Aplicaciones. Quiere establecerse en 040775. Puedo arreglarlo ejecutando chmod 040775
, pero no entiendo qué significan los primeros 2 dígitos. Simplemente ejecutar chmod 775
no funciona, por lo que aparentemente estos primeros 2 dígitos son incorrectos. ¿Qué son estos 2 dígitos y cómo puedo verlos en macOS? Estoy buscando algo como ls -l
. Estoy ejecutando High Sierra.
La respuesta corta es stat y pide el campo de permisos:
stat -f "%p" file
Es probable que esa aplicación, instrucciones o memoria estén mal. Desde la página del manual, hay 4 dígitos en la representación octal para modos en macOS:
Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values: 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner. Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to mount(8). 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner. 1000 (the sticky bit) See chmod(2) and sticky(8). 0400 Allow read by owner. 0200 Allow write by owner. 0100 For files, allow execution by owner. For directories, allow the owner to search in the directory. 0040 Allow read by group members. 0020 Allow write by group members. 0010 For files, allow execution by group members. For directo- ries, allow group members to search in the directory. 0004 Allow read by others. 0002 Allow write by others. 0001 For files, allow execution by others. For directories allow others to search in the directory. For example, the absolute mode that permits read, write and execute by the owner, read and execute by group members, read and execute by others, and no set-uid or set-gid behaviour is 755 (400+200+100+040+010+004+001).
Creé un archivo convenientemente llamado 040775 y apliqué permisos: puede ver que 040 borra todos los adhesivos (ya que es 0775 la parte que importa), setUID, setGID bits para que obtenga 0775 si intenta configurar 040775.
mac:foo me$ touch 040775
mac:foo me$ stat -f "%p" 040775
100644
mac:foo me$ chmod 040775 040775
mac:foo me$ stat -f "%p" 040775
100775
mac:foo me$ chmod 4775 040775
mac:foo me$ ls -l
-rwsrwxr-x 1 me wheel 0 May 10 20:30 040775
mac:foo me$ chmod 040775 040775
mac:foo me$ ls -l
-rwxrwxr-x 1 me wheel 0 May 10 20:30 040775
Edité un poco lo anterior y no hice todo el stat
y ls
, pero debería ayudarlo a hurgar en los archivos existentes y probar si mi experiencia de que solo los últimos 4 dígitos se interpretan como una máscara de bits octal para establecer permisos como está documentado en la página de manual de chmod.
0
borra 0775
todo pegajoso. 04
of 040775
se ignora y lo digo porque si primero establece eg 4775
y luego usa 010775
, hace lo mismo que 040775
does y 01
of 010775
se ignora al igual que 04
of 040775
y chmod
simplemente lo procesa como 0775
en ambos ejemplos.stat -f %p filename
. "04" significa que es un directorio. Tal vez en este caso chmod 0775
tendría el mismo efecto. Pero chmod parece ser algo consciente de esto porque chmod 240775
da un error, mientras que chmod 140775
no lo hace. systutorials.com/docs/linux/man/2-stat240775
genera un error porque este valor no se puede almacenar en un número entero de 16 bits, mientras que 140775
se puede almacenar.
usuario3439894
040775
seachmod 040775
un permiso válido. Le sugiero que lea laMODES
sección delman page
forchmod
. Probablemente quieras:chmod 4775
Elliott
usuario3439894
chmod
comando , no puedo decirlo específicamente, sin embargo,04
se040775
ignora y0775
establece los permisos enrwxrwxr-x
y los paquetes de aplicaciones normales y los archivos ejecutables normales generalmente se establecen enrwxr-xr-x
.fd0