File Permissions and Ownership

The stat(2) family of functions allows you to inquire about a file system object's permissions and ownership. Permissions are described by the stat structure member st_mode. To alter this permission setting, you change its mode. This is covered next, using the functions chmod(2), fchmod(2), and lchmod(2).

Each user on a UNIX system owns files that he has created. He is the owner of his files and, as the owner, possesses the right to change its permissions (mode). Likewise, the user is a member of a group. Consequently, there exists group ownership on file system objects. The owner of a file (with exceptions) can give his ownership away to another user or group on the system. This is known as changing the owner or ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.