Information Technology Reference
In-Depth Information
-rw-r--r-- 1 guest other 636 Jun 28 07:39 list
# chown sys:staff data junk list
# ls -l
total 18
-rw-rw-rw- 1 sys staff 120 Jun 28 07:38 data
-rw-rw-rw- 1 sys staff 6528 Jun 28 07:38 junk
-rw-r--r-- 1 sys staff 636 Jun 28 07:39 list
#
Changing the File Group Account
The chgrp command is used to change the file group account associated with
a file or directory. Only the user account that currently owns the file or the
superuser account (root) can change file ownership. By default, the owner of
a file can change only a group account to which the user belongs.
The group account name or associated GID is specified along with the name
of one or more files that should be owned by the specified group account.
The following listing shows the chgrp command being used to change the
ownership of several files to the other group account, which has a GID of 1.
Each chgrp command is preceded and followed by the ls command, which
is used to list the ownership and permissions of files:
# ls -l
total 18
-rw-rw-rw- 1 sys staff 120 Jun 28 07:38 data
-rw-rw-rw- 1 sys staff 6528 Jun 28 07:38 junk
-rw-r--r-- 1 sys staff 636 Jun 28 07:39 list
# chgrp other junk
# ls -l
total 18
-rw-rw-rw- 1 sys staff 120 Jun 28 07:38 data
-rw-rw-rw- 1 sys other 6528 Jun 28 07:38 junk
-rw-r--r-- 1 sys staff 636 Jun 28 07:39 list
# chgrp 1 data list
# ls -l
total 18
-rw-rw-rw- 1 sys other 120 Jun 28 07:38 data
-rw-rw-rw- 1 sys other 6528 Jun 28 07:38 junk
-rw-r--r-- 1 sys other 636 Jun 28 07:39 list
#
Like the chown command, the chgrp command supports a recursive command-
line argument, -R . When used to change the group ownership of a directory, the
group ownership of any files or subdirectories under the directory also changes.
If the chgrp command is used by anyone (other than root) who does not have
the appropriate permissions and the file has the setuid special permission
and/or the setgid special permission, the setuid and/or getuid special per-
mission is cleared. This prevents a user from setting up a setuid and/or
setgid file, changing the ownership to someone else, and then using the file
to gain access to another user account and/or group account.
Search WWH ::




Custom Search