This section describes how to change the ownership of a file.
By default, the owner cannot use the chown command to change the owner of a file or directory. However, you can enable the owner to use chown by adding the following line to the system's /etc/system file and rebooting the system.
set rstchown = 0 |
See chown(1) for more details. Also, be aware that there can be other restrictions on changing ownership on NFS-mounted file systems.
Change the owner of a file by using the chown command.
# chown newowner filename |
newowner |
Specifies the user name or UID of the new owner of the file or directory. |
filename |
Specifies the file or directory. |
Verify the owner of the file is changed.
# ls -l filename |
The following example sets the ownership on myfile to the user rimmer.
# chown rimmer myfile # ls -l myfile -rw-r--r-- 1 rimmer scifi 112640 May 24 10:49 myfile |
By default, the owner can only use the chgrp command to change the group of a file to a group in which the owner belongs. For example, if the owner of a file only belongs to the staff and sysadm groups, the owner can only change the group of a file to staff or sysadm group.
However, you can enable the owner to change the group of a file to a group in which the owner doesn't belong by adding the following line to the system's /etc/system file and rebooting the system.
set rstchown = 0 |
See chgrp(1) for more details. Also, be aware that there can be other restrictions on changing groups on NFS-mounted file systems.
Change the group owner of a file by using the chgrp command.
$ chgrp group filename |
group |
Specifies the group name or GID of the new group of the file or directory. |
filename |
Specifies the file or directory. |
See "Setting Up and Maintaining User Accounts and Groups (Tasks)" in System Administration Guide, Volume 1 for information on setting up groups.
Verify the group owner of the file is changed.
$ ls -l filename |
The following example sets the group ownership on myfile to the group scifi.
$ chgrp scifi myfile $ ls -l myfile -rwxrw-- 1 rimmer scifi 12985 Nov 12 16:28 myfile |