Go to main content

Securing Files and Verifying File Integrity in Oracle® Solaris 11.4

Exit Print View

Updated: August 2018
 
 

How to Change the Owner of a File

Before You Begin

If you are not the owner of the file or directory, you must be assigned the Object Access Management rights profile. To change a file that is a public object, you must assume the root role.

For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.4.

  1. Display the permissions on a local file.
    % ls -l example-file
    -rw-r--r--   1 janedoe   staff   12K May 24 10:49 example-file
  2. Change the owner of the file.
    # chown stacey example-file
  3. Verify that the owner of the file has changed.
    # ls -l example-file
    -rw-r--r--   1 stacey   staff   12K May 31 08:58 example-file 

    To change permissions on NFS-mounted files, see Chapter 5, Commands for Managing Network File Systems in Managing Network File Systems in Oracle Solaris 11.4.

Example 2  Enabling Users to Change the Ownership of Their Own Files

Security Consideration – You need a good reason to change the setting of the rstchown variable to zero. The default setting prevents users from listing their files as belonging to others so as to bypass space quotas.

In this example, the value of the rstchown variable is set to zero in the /etc/system file. This setting enables the owner of a file to use the chown command to change the file's ownership to another user. This setting also enables the owner to use the chgrp command to set the group ownership of a file to a group that the owner does not belong to. The change goes into effect when the system is rebooted.

set rstchown = 0

For more information, see the chown(1) and chgrp(1) man pages.