Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

chown - change file ownership

&pagelevel(4)&pagelevel

chown assigns a new owner to a file or a directory.

Only the POSIX administrator may change the owner of a file.


Syntax


chown[ -h][ -R] uid[:gid] file ...

-h

If file is a symbolic link, chown changes the owner of the symbolic link. Without this option, the owner of the file referenced by the symbolic link is changed.

-R

(recursive)
chown recursively descends through the specified directories, changing the file owner as it proceeds and traversing any symbolic links that it encounters.

uid[:gid]

Login name or user ID of the new owner. Optionally, the group ID may also be specified.

file

Name of the file that is to have a new owner. Directories and multiple file names are also allowed.

Error

chown: file: Not super-user
You may not change the owner of the file file since you are not the POSIX administrator.


chown: Unknown user: newowner
You have entered a user ID for newowner which is not entered in the user table.

Locale

The following environment variables affect the execution of chown:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments). LC_CTYPE governs character classes, character conversion (shifting) and the behavior of character classes in regular expressions.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example

You are working as the POSIX administrator and want to change the owner of a file. You wish to assign the new owner MARK to the file text1 whose owner is CATHY. To do this, enter:

# ls -l text1
-rw-------   1 CATHY    ag          2426   Feb 17 15:48 text1
# chown mark text1
# ls -l text1
-rw-------   1 MARK     ag          2426   Feb 17 15:48 text1

See also

chgrp, chmod

chown() [4]