# chattr con Apple MacOs X

## chattr en linux
Uno de los elementos que uso en mis sistemas linux, cuando hay ciertas cosas que quiero proteger de escrituras accidentales o provocadas, es `chattr` un poderos comando que marca con una bandera de inmutabilidad el fichero indicado, si lo usamos con la opción `+i`

```
# chattr +i file_inmutable.txt
```

Con ese comando ni el propio root podrá editar o borrar el fichero hasta que

```
# chattr -i file_inmutable.txt
```


> A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.


Sin embargo en mi oficina como ordenador de escritorio uso Mac OsX, y es un poco de diferente. Te presento el comando `chflags`

## chflags

Si acudimos al **man* del comando 

```
schg, schange, simmutable
                       set the system immutable flag (super-user only)
uchg, uchange, uimmutable
                       set the user immutable flag (owner or super-user only)
                       
Putting the letters “no” before or removing the letters “no” from a keyword causes the flag to be cleared.  For example:

           nouchg  clear the user immutable flag (owner or super-user only)                       
                       
```

Así que sencillo si queremos proteger contra una posible escritura o borrado un fichero en nuestro mac.

```
> chflags uchg config.xml
```

##### Aviso
Esta documentación y su contenido, no implica que funcione en tu caso o determinados casos. 
También implica que tienes conocimientos sobre lo que trata, y que en cualquier caso tienes copias de seguridad.
El contenido el contenido se entrega, tal y como está, sin que ello implique ningún obligación ni responsabilidad por parte de [Castris](https://castris.com)

Si necesitas soporte profesional puedes contratar con Castris [soporte profesional](https://intranet.castris.com/store/soporte-profesional).