Chgrp


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

chgrp - change group ownership

Synopsis - man page

chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...

Frequently used options

-R, --recursive
      operate on files and directories recursively

Examples

Lets create directories in /tmp to test chgrp command.

# cd /tmp
# mkdir -p directory1/directory2
Image:chgrp01.gif

also we can create file in /tmp/directory1/directory2

# touch /tmp/directory1/directory2/file
# ls -ld /tmp/directory1/directory2/
# ls -l directory1/directory2/
Image:chgrp02.gif

At this stage as we can see the group ownership is assigned to root for both directories and file. To change ownership of directory1 to linuxconfig we can enter command:

# chgrp linuxconfig /tmp/directory1/
# ls -ld /tmp/directory1/
# ls -ld /tmp/directory1/directory2/
Image:chgrp03.gif

The group ownership of directory1 has been changed to linuxconfig. To change group ownership of directory2 and file within directory2 we can use recursive options -R.

# chgrp -R linuxconfig /tmp/directory1/
# ls -ld /tmp/directory1/
# ls -ld /tmp/directory1/directory2/
# ls -l /tmp/directory1/directory2/
Image:chgrp04.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands