Chown

From Wikipedia, the free encyclopedia

The correct title of this article is chown. The initial letter is shown capitalized due to technical restrictions.

The chown command is used on Unix-like systems to change the owner of a file. In most implementations, it can only be executed by the Superuser. Unprivileged (regular) users who wish to change the group of a file that they own may use chgrp.

Contents

The general syntax for the chown command is:

chown [-hHLPR] [[user]] [:group] target1 [[target2 ..]]
  • The optional user parameter indicates the new user who should take ownership of the targets.
  • The optional group parameter (which must be prefixed with a colon, :) indicates the group with which the targets should be associated.
  • The target parameters indicate the files or directories for which the user and/or group will be changed.

-h
 If the system supports user IDs for symbolic links, for each file operand that names a file of type symbolic link, chown shall attempt to set the user ID of the symbolic link. If the system supports group IDs for symbolic links, and a group ID was specified, for each file operand that names a file of type symbolic link, chown shall attempt to set the group ID of the symbolic link. If the system does not support user or group IDs for symbolic links, for each file operand that names a file of type symbolic link, chown shall do nothing more with the current file and shall go on to any remaining files.

-H
 If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line, chown shall change the user ID (and group ID, if specified) of the directory referenced by the symbolic link and all files in the file hierarchy below it.

-L
 If the -R option is specified and a symbolic link referencing a file of type directory is specified on the command line or encountered during the traversal of a file hierarchy, chown shall change the user ID (and group ID, if specified) of the directory referenced by the symbolic link and all files in the file hierarchy below it.

-P
 If the -R option is specified and a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy, chown shall change the owner ID (and group ID, if specified) of the symbolic link if the system supports this operation. The chown utility shall not follow the symbolic link to any other part of the file hierarchy.

-R
 Recursively change file user and group IDs. For each file operand that names a directory, chown shall change the user ID (and group ID, if specified) of the directory and all files in the file hierarchy below it. Unless a -H, -L, or -P option is specified, it is unspecified which of these options will be used as the default.

 The following environment variables shall affect the execution of chown:

 LANG
  Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
 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-byte as opposed to multi-byte characters in arguments).
 LC_MESSAGES
  Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
 NLSPATH
  [XSI] [Option Start] Determine the location of message catalogs for the processing of LC_MESSAGES . [Option End]


  • One of either user or group must be specified. The chown command will not execute properly without at least one of those parameters.
  • The user and group parameters can be either symbolic names or identifiers (i.e. a User ID or Group ID).

# chown root /var/run/httpd.pid
  • Change the owner of /var/run/httpd.pid to 'root' (the standard name for the Superuser).
# chown nobody:nobody /tmp /var/tmp
  • Change the owner of /tmp and /var/tmp to ‘nobody’ (not a good idea)
  • Change the group associated with the same targets to the group ‘nobody’ (conventially the ‘nobody’ user's group)
# chown :512 /home
  • Change the group identifier of /home to 512 (regardless of whether a group name is associated with the identifier 512 or not).
# chown -R us ./base
  • Change the ownership of ./base to the user us and make it recursive (-R)


Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.