Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

chown

Changes the owner and group of one or more files.

Changes the owner and group of each listed file. The first argument is the numeric UID, the second is the numeric GID, and the remaining arguments are file paths. A value of -1 for either UID or GID means “don’t change that field” (converted to u32::MAX for the libc call). Uses libc::chown (follows symlinks). Returns the number of files successfully changed.

Synopsis

chown $uid, $gid, @files;
chown 0, 0, '/etc/shadow';
chown -1, $gid, @files;    # -1 leaves uid unchanged

See Also

chmod, stat