Objective 6: Manage File Ownership
Modification of ownership parameters may become necessary when moving files, setting up workgroups, or working in a user's directory as root. This is accomplished using the chown command, which can change user and group ownership, and the chgrp command for modifying group ownership.
chown
- Syntax
chown [
options] user-owner files
chown [options] user-owner. files
chown [options] user-owner.group-owner files
chown [options
] .group-owner files
chown [options
] --reference
=rfile files
- Description
Used to change the owner and/or group of
files
touser-owner
and/orgroup-owner
. In the first form,user-owner
is made the owner offiles
and the group is not affected. In the second form (note the trailing dot onuser-owner
), theuser-owner
is made the owner offiles
and the group of the files is changed touser-owner
's default group. In the third form, bothuser-owner
andgroup-owner
are assigned tofiles
. In the fourth form, only thegroup-owner
is assigned tofiles
, and the user is not affected. In the fifth form, the owner and group ofrfile
is used as a template and applied tofiles
. Only the superuser may change file ownership, but group ownership may be set by anyone belonging to the targetgroup-owner
.Tip
Note that historically BSD systems have used the
user
.
group
syntax, but SysV-based systems have useduser
:
group
(:
instead of.
). Older versions of GNU chown only accepted the BSD syntax, but recent versions support both.- Frequently used options ...
Get LPI Linux Certification in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.