[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 1

chown Command

Purpose

Changes the owner or group associated with a file.

Syntax

chown-f ] [ -h ] [  -R ] Owner :Group ] { File ... Directory ... }

Description

The chown command changes the owner of the file specified by the File parameter to the user specified by the Owner parameter. The value of the Owner parameter can be a user ID or a login name found in the /etc/passwd file. Optionally, a group can also be specified. The value of the Group parameter can be a group ID or a group name found in the /etc/group file.

Only the root user can change the owner of a file. You can change the group of a file only if you are a root user or if you own the file. If you own the file but are not a root user, you can change the group only to a group of which you are a member.

When a symbolic link is encountered and you have not specified the -h flag, the chown command changes the ownership of the file or directory pointed to by the link and not the ownership of the link itself.

If you specify the -h flag, the chown command has the opposite effect and changes the ownership of the link itself and not that of the file or directory pointed to by the link.

If you specify the -R flag, the chown command recursively descends the specified directories.

If you specify both the -h flag and the -R flag, the chown command descends the specified directories recursively, and when a symbolic link is encountered, the ownership of the link itself is changed and not that of the file or directory pointed to by the link.

Flags

-f Suppresses all error messages except usage messages.
-h Changes the ownership of an encountered symbolic link and not that of the file or directory pointed to by the symbolic link.
-R Descends directories recursively, changing the ownership for each file. When a symbolic link is encountered and the link points to a directory, the ownership of that directory is changed but the directory is not further transversed.

Security

Access Control: This program should be installed as a normal user program in the Trusted Computing Base.

Exit Status

This command returns the following exit values:

0 The command executed successfully and all requested changes were made.
>0 An error occurred.

Examples

  1. To change the owner of the file program.c:

    chown jim program.c

    The user access permissions for program.c now apply to jim. As the owner, jim can use the chmod command to permit or deny other users access to program.c.

  2. To change the owner and group of all files in the directory /tmp/src to owner john and group build:

    chown -R john:build /tmp/src

Files

/usr/bin/chown The chown command
/etc/group File that contains group IDs
/etc/passwd File that contains user IDs

Related Information

The chgrp command, chmod command.

The chown subroutine, fchown subroutine.

The File Ownership and User Groups in AIX 5L Version 5.2 System User's Guide: Operating System and Devices introduces file ownership and permissions to access files and directories.

The Security Administration in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices describes system security.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]