Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > C

chown(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

chown, chgrp — change file owner or group

SYNOPSIS

chown [-h] [-R [-H|-L|-P ] ] owner [: group] file ...

chgrp [-h] [-R [-H|-L|-P ] ] group file ...

DESCRIPTION

The chown command changes the owner ID of each specified file to owner and optionally the group ID of each specified file to group.

The chgrp command changes the group ID of each specified file to group.

In order to change the owner or group, you must own the file and have the CHOWN privilege (see setprivgrp(1M)). If either command is invoked on a regular file by other than the superuser, the set-user-ID and set-group-ID bits of the file mode (04000 and 02000 respectively) are cleared. Note that a given user's or group's ability to use this command can be restricted by setprivgrp (see setprivgrp(1M)).

Options

chown and chgrp recognize the following options:

-h

Change the owner or group of a symbolic link.

By default, the owner or group of the target file that a symbolic link points to is changed. With -h, the target file that the symbolic link points to is not affected. If the target file is a directory, and you specify -h and -R, recursion does not take place.

-H

If the -R option is specified and a symbolic link referencing a directory is specified on the command line, the owner or group of the directory referenced by the symbolic link and all files in the file hierarchy below it are changed.

-L

If the -R option is specified and a symbolic link referencing a directory is encountered on the command line or during the traversal of a file hierarchy, the owner or group of the directory referenced by the symbolic link and all files in the file hierarchy below it are changed.

-P

If the -R option is specified and a symbolic link is encountered on the command line or during the traversal of a file hierarchy, the owner or group of the symbolic link are changed. The chown utility shall not follow the symbolic link to any other part of the file hierarchy.

-R

Recursively change the owner or group. For each file operand that names a directory, the owner or group of the directory and all files and subdirectories in the file hierarchy below it are changed.

Operands

chown and chgrp recognize the following operands:

file

Target file for which the ownership is changed.

group

Either a decimal group ID or a group name found in the /etc/group file.

owner

Either a decimal user ID or a login name found in the /etc/passwd file.

Access Control Lists - HFS File Systems Only

Users can permit or deny specific individuals and groups to access a file by setting optional ACL entries in the file's access control list (see acl(5)). When using chown in conjunction with HFS ACLs, if the new owner and/or group of a file does not have an optional ACL entry corresponding to user.% and/or %.group in the file's access control list, the file's access permission bits remain unchanged. However, if the new owner and/or group is already designated by an optional ACL entry of user.% and/or %.group in the file's ACL, chown sets the corresponding file access permission bits (and the corresponding base ACL entries) to the permissions contained in that entry.

Access Control Lists - JFS File Systems Only

Users can permit or deny specific individuals and groups to access a file by setting optional ACL entries in the file's access control list (see aclv(5)). When using chown in conjunction with JFS ACLs, if the new owner and/or group of a file have optional ACL entries corresponding to user:uid:perm and/or group:gid:perm in the file's access control list, those entries remain in the ACL but no longer have any effect, being superseded by the file's user::perm and/or group::perm entries.

Options

chown and chgrp recognize the following options:

-h

Change the owner or group of a symbolic link.

By default, the owner or group of the target file that a symbolic link points to is changed. With -h, the target file that the symbolic link points to is not affected. If the target file is a directory, and you specify -h and -R, recursion does not take place.

-R

Recursively change the owner or group. For each file operand that names a directory, the owner or group of the directory and all files and subdirectories in the file hierarchy below it are changed.

EXTERNAL INFLUENCES

Environment Variables

LC_MESSAGES determines the language in which messages are displayed.

If LC_MESSAGES is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.

If any internationalization variable contains an invalid setting, chown behaves as if all internationalization variables are set to "C". See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported.

RETURN VALUE

chown and chgrp return the following values:

0

Successful completion.

>0

An error condition occurred.

EXAMPLES

The following command changes the owner of the file jokes to sandi:

chown sandi jokes

The following command searches the directory design_notes and changes each file in that directory to owner mark and group users:

chown -R mark:users design_notes

WARNINGS

The default operation of chown and chgrp for symbolic links has changed as of HP-UX release 10.0. Use the -h option to get the former default operation.

FILES

/etc/group /etc/passwd

STANDARDS CONFORMANCE

chown: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

chgrp: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.