CHOWN, short for Change Owner, is a command-line utility in Unix-like operating systems, including Linux and macOS, used to change the ownership of files and directories. Developed as part of the original Unix system in the 1970s, CHOWN allows system administrators and users with appropriate privileges to assign a file or directory to a different user and/or group. It is accessible via terminal shells such as bash or zsh, and detailed usage documentation can be found in the system manual (man chown) or at the GNU Coreutils CHOWN Manual.

CHOWN exists to manage ownership of files and directories, which is critical for enforcing security, access control, and accountability in multi-user environments. Its design emphasizes precision, flexibility, and compatibility with symbolic and recursive operations, allowing administrators to clearly and efficiently manage permissions and system resources.

CHOWN: Basic Usage

Ownership can be changed for the user and group using the syntax chown user:group filename.

# change the owner of a file to alice and group to staff
chown alice:staff document.txt

# change only the owner, keeping the group unchanged
chown bob document.txt

# change only the group, keeping the owner unchanged
chown :admin script.sh

This approach allows administrators to assign precise ownership to files and directories. Similar concepts appear in CHMOD and Unix File Permissions.

CHOWN: Recursive Ownership Changes

The -R flag allows CHOWN to recursively change ownership for a directory and all its contents.

# recursively change ownership of a project directory
chown -R alice:staff /home/alice/projects

Recursive changes are essential for managing large directories and ensuring consistent ownership, especially in collaborative environments. Administrators often combine recursive CHOWN with CHMOD to fully control access and permissions.

CHOWN: Using Numeric UID and GID

Users can specify numeric user IDs (UIDs) and group IDs (GIDs) instead of names to change ownership programmatically.

# change ownership using numeric UID and GID
chown 1001:100 staff_document.txt

Numeric specification is especially useful in scripts and automated systems where user and group names may vary between systems. This is similar in concept to numeric permission settings in CHMOD.

CHOWN is used in system administration, scripting, and deployment workflows to assign proper file and directory ownership. Combined with CHMOD and understanding of Unix File Permissions, it ensures secure and orderly access control in multi-user Unix-like systems.