Users can modify the owner and group of files or directories that they own by using the chown command. Regular users cannot modify the ownership of files or directories that they do not own. Members of the sysadmin group, however, can use the vchown super command to modify the owner and group of files and directories that are owned by other users, except for those owned by the user root. The root user can use the chown command to change the ownership of any file.
Examples of changing the ownership of files are given below.
Example 1: Changing ownership of a file with chown
In this example, assume that your username is jdoe and that you are changing the ownership on the following file, which is currently owned by you:
-rw-r----- 1 jdoe jdoe 0 Jan 21 07:28 mailing.list
To change the group of this file so that it belongs to the mailadmin group, you can use the following:
> chown jdoe.mailadmin mailing.list
You can verify the new ownership by issuing the ll command. The group ownership should now reflect 'mailadmin' for the file, as shown below:
-rw-r----- 1 jdoe mailadmin 0 Jan 21 07:28 mailing.list
Example 2: Changing ownership of file owned by someone else
Recall that users who are members of the sysadmin group can modify ownership of files owned by anyone except the root user. Suppose you are a member of the sysadmin group and need to take ownership of the following file, which is owned by the user sally and the group acme.com:
-rw-r----- 1 sally acme.com 0 Jan 21 07:28 index.html
You can do so with the following command:
> vchown jdoe.acme.com index.html
For More Information:
For more information on file ownership, please refer to the chown man page by entering the following command at the command prompt:
> man chown