System Administration Guide

Changing File Ownership

This section describes how to change the ownership of a file.

How to Change the Owner of a File

  1. If you are not the owner of the file or directory, become superuser.

    Only the current owner or superuser can use the chown command to change the owner of a file or directory.

  2. Change the owner of a file by using the chown command.


    $ chown newowner   filename
    

    newowner

    Name of the new owner of the file or directory. 

    filename

    File or directory. 

  3. Verify the owner of the file is changed.


    $ ls -l filename
    

Example--Changing the Owner of a File

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

How to Change Group Ownership of a File

  1. If you are not the owner of the file or directory, become superuser.

    Only the current owner or superuser can use the chgrp command to change the group of a file or directory.

  2. Change the group owner of a file by using the chgrp command.


    $ chgrp group filename
    

    group

    Name of the new group of the file or directory. 

    filename

    File or directory. 

  3. Verify the group owner of the file is changed.


    $ ls -l filename
    

Example--Changing Group Ownership of a File

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