feed-image  Delivered by FeedBurner  ISSN 1836-5930





Poll

Which of following tutorials would you like to see on the Linuxconfig.org?
 
Partner Linux Sites
TuxMachines
DebianAdmin
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
FreeSoftwareLinux
Jam's Ubuntu Blog
All For Linux

chgrp
Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

1. Name

chgrp [man page] - change group ownership

2. Synopsis

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

3. Frequently used options

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

4. Examples

Lets create directories in /tmp to test chgrp command.
# cd /tmp
# mkdir -p directory1/directory2
chgrp create directories
also we can create file in /tmp/directory1/directory2
# touch /tmp/directory1/directory2/file
# ls -ld /tmp/directory1/directory2/
# ls -l directory1/directory2/
chgrp create file
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/
change ownership of directory
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/
change group ownership of directory and file