Ir al contenido

File Ownership and Permissions Management (takeown and icacls)

Advanced file security control, ownership acquisition (takeown), and access control list (icacls) manipulation in Windows.

0views

In Windows operating systems, NTFS file system security is managed through access control lists (ACL). After having created users and security groups in the previous sections, in this technical guide you will learn to coordinate these elements to define specific access, take ownership of locked directories, and surgically audit permissions using the takeown and icacls commands.


To operate securely in the console, it is fundamental to understand how the Windows permissions and access control layer works:

  • Owner (Owner): Each file and directory has an "owner". The owner is guaranteed by the operating system the right to modify the object's permission lists, even if they explicitly lack read or write access.
  • ACL (Access Control List): A metadata table associated with each file or folder that contains the list of individual access control entries (ACEs) that Windows evaluates upon receiving read, write, or execute requests.
  • ACE (Access Control Entry): An individual rule within the ACL. For example: Allow Full Control to the “Administrators” group or Deny Write to the “Guests” group.
  • Inheritance (Inheritance): Automatic propagation of permission directives from a container folder to all files and subfolders contained within it.

2. Taking Possession and Ownership (takeown)

Sección titulada «2. Toma de Posesión y Propiedad (takeown)»

Sometimes, security directives prevent even Administradores group accounts from having read access to certain critical system files. In these scenarios, the mandatory first step is to take physical possession of the resource.

This command assigns ownership of the specified file to the user currently authenticated in the elevated terminal:

Ventana de terminal
takeown /f "C:\Sistemas\config.log"

B. Taking Possession of a Directory and its Content (Recursive)

Sección titulada «B. Tomar Posesión de un Directorio y su Contenido (Recursivo)»

Ideal for recovering orphaned folders after migrations or operating system reinstalls. The /r parameter indicates full recursivity:

Ventana de terminal
takeown /f "C:\DatosPrivados" /r

C. Assigning Ownership to the Administrators Group (Best Practices)

Sección titulada «C. Asignar la Propiedad al Grupo Administradores (Buenas Prácticas)»

In professional administration environments, the technical recommendation is to assign ownership to the Administradores group container instead of an individual user account:

Ventana de terminal
takeown /f "C:\DatosPrivados" /r /a

Before making modifications, it is mandatory to inspect and document the current access table of the affected directories:

Ventana de terminal
icacls "C:\Datos\Facturas"

Example console output:

C:\Datos\Facturas BUILTIN\Administradores:(I)(OI)(CI)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
BUILTIN\Usuarios:(I)(OI)(CI)(RX)
CREATOR OWNER:(I)(OI)(CI)(IO)(F)
  • (I): Inherited (Inherited). Indicates that the permission is derived from a parent folder.
  • (OI): Object Inherit (Object Inherit). Files within this folder will inherit the rule.
  • (CI): Container Inherit (Container Inherit). Subfolders will inherit the rule.
  • (IO): Inherit Only (Inherit Only). The permission does not apply to this parent folder, only to its descendants.
  • (F): Full Control (Full Control).
  • (M): Modify (Modify). Allows reading, writing, executing, and deleting.
  • (RX): Read and Execute (Read & Execute)
  • (R): Read-only (Read-only).
  • (W): Write-only (Write-only).

4. Configuration and Granting of Permissions with icacls

Sección titulada «4. Configuración y Concesión de Permisos con icacls»

The standard method for adding rules to access control tables:

Ventana de terminal
:: Otorgar Control Total al grupo departamental "Contabilidad"
icacls "C:\Datos\Facturas" /grant Contabilidad:(F)
:: Otorgar permisos recursivos correctos (para archivos y carpetas dentro)
icacls "C:\Datos\Facturas" /grant Contabilidad:(OI)(CI)(F) /t

Define absolute restriction rules.

Deny Priority

In Windows NTFS architecture, a Deny rule has absolute priority and overrides any Grant rule. If a user belongs to two different groups and one has access assigned while the other has a restriction, the restriction will prevail immediately. Use it with extreme caution.

Ventana de terminal
:: Denegar explícitamente el acceso de escritura al usuario "Invitado"
icacls "C:\Datos\Facturas" /deny Invitado:(W) /t

The clean and recommended way to revoke access by removing the rule entirely instead of adding conflicting restrictions:

Ventana de terminal
:: Eliminar todas las reglas asociadas al usuario "Invitado"
icacls "C:\Datos\Facturas" /remove Invitado /t

5. Advanced Inheritance Management and Reset

Sección titulada «5. Gestión Avanzada de Herencia y Reseteo»

A. Break Inheritance and Preserve Current Permissions

Sección titulada «A. Romper Herencia y Preservar Permisos Actuales»

If you want a folder to stop receiving automatic permissions from its parent root directory to establish exclusive policies:

Ventana de terminal
icacls "C:\Datos\FacturasSecretas" /inheritance:d /copy
  • /inheritance:d: Disable and block upper inheritance.
  • /copy: Clone the currently active inherited permissions and convert them into fixed local rules so as not to lose access abruptly.

If you have made an assignment error and have blocked entire production directories, this command restores the default inherited directives from the operating system:

Ventana de terminal
icacls "C:\Datos\Facturas" /reset /t

It is mandatory to make backups of complex permission configurations before performing mass maintenance:

Ventana de terminal
:: Guardar configuración actual en un archivo de respaldo
icacls "C:\Datos" /save "C:\Backups\permisos_datos.txt" /t
:: Restaurar la copia de seguridad exacta (Ejecutar desde la raíz C:\)
icacls "C:\" /restore "C:\Backups\permisos_datos.txt"