CST BrandsHelpdesk Command Line LinuxHow Do I Change the Owner and Group of a File

How Do I Change the Owner and Group of a File

Determine File Ownership

Determine File Ownership

Use the "ls" command with the "-l" option followed by the file name to display all information about the file.  In this lesson, we are interested in the User and Group that own the file.

(1) User - The username of the person who owns the file. By default, the user who creates the file will become its owner.

(2) Group - The usergroup that owns the file. All users who belong into the group that owns the file will have the same access permissions to the file.

Change File Ownership

Change File Ownership

The "chown" command is used to change the User and Group that own a file.  The basic syntax is chown  new_user : new_group  filename.  In this example, we are changing the User that owns stock.dat from "root" to "mws2" and the Group that owns stock.dat from "root" to "users."

File Ownership Has Changed

File Ownership Has Changed

Now, when the file information is displayed, you can see that the User and Group ownership have changed.

chown

chown

In order to use the "chown" command one must first be logged in as root user.  If "chown" is attempted as any other user, an error message similar to the following will be displayed.

0 Comments

Add your comment

E-Mail me when someone replies to this comment