Skip to Content
APIchown

chown

Change the owner and group of a file or directory (Unix). On Windows this is a no-op or limited.

Basic usage

import { chown } from '@rush-fs/core' await chown('./file', uid, gid)

Methods

chown(path, uid, gid)

Async. Returns Promise<void>.

ArgumentTypeDescription
pathstringFile or directory path.
uidnumberUser id.
gidnumberGroup id.

chownSync(path, uid, gid)

Sync. Same arguments; throws on error (e.g. EPERM).

Performance

Single syscall; on par with Node.js. See Benchmarks.

Notes

  • Windows: Typically requires elevated privileges or has no effect; same as Node.js.
  • Root: Changing ownership usually requires root/sudo on Unix.
Last updated on