Permissions · Lesson 3 of 8

Ownership Permissions

0 / 4 checkpoints answered

Full screen ↗

Every Linux filesystem object records a user owner and a group owner. These identities determine which owner or group permission triplet applies, but they do not themselves grant a particular permission. Inspect both ownership and mode with ls -l.

Changing the User Owner

Use chown, short for change owner, to assign a different user owner:

$ sudo chown patty myfile

This changes the user owner of myfile to patty and leaves its group unchanged. Changing a file's user owner normally requires appropriate privilege, even if you currently own the file. This restriction prevents users from transferring files to evade quotas or other ownership-based controls.

CheckWhich command changes the user owner of myfile to patty while leaving its group unchanged?

Changing the Group Owner

Use chgrp to assign a different group owner:

$ chgrp whales myfile

On typical systems, an unprivileged owner can change a file's group only to a group of which that user is a member. Privileged processes can make broader changes. The equivalent chown form begins with a colon:

$ chown :whales myfile

Afterward, the group's mode bits apply when the kernel selects the group class; changing the group does not automatically add read, write, or execute bits.

CheckWhat does chgrp whales myfile change?

Changing User and Group Together

Supply USER:GROUP to chown to update both fields in one operation:

$ sudo chown patty:whales myfile

The command assigns patty as the user owner and whales as the group owner. Verify the result rather than assuming it succeeded:

$ ls -l myfile

CheckWhich ownership specification assigns user patty and group whales in one chown command?

Handling Recursive Changes Carefully

The -R option changes ownership recursively, but a broad recursive command can cross unexpected directory trees or affect service data. Confirm the exact target, understand symbolic-link behavior for your implementation, preview the tree, and verify a small sample before changing a large hierarchy. Avoid copying privileged ownership commands from examples onto real systems without reviewing their scope.

CheckAfter changing a file's group owner, what happens to its ordinary group permission bits?

For practice in an isolated environment, the Linux User Group and File Permissions lab covers inspecting and modifying ownership alongside file modes.

Summary

You can now distinguish ownership metadata from permission bits and change it deliberately.

  1. Use chown USER FILE to change the user owner.
  2. Use chgrp GROUP FILE or chown :GROUP FILE to change the group owner.
  3. Use chown USER:GROUP FILE to set both fields.
  4. Verify results and scope recursive changes carefully.