RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
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

Let's first create same sample directories in /tmp to test chgrp command. The following mkdir command will create two directories: directory1 and directory2 where directory1 is a parent of directory2.

# cd /tmp
# mkdir -p directory1/directory2

chgrp create directories
Next we can also create a 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 that group ownership is assigned to a root for both directories and file. To change an ownership of directory1 to linuxconfig group we can enter command:

NOTE: the group must exists in order to take ownership of a file or directory

# 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 a group ownership of directory2 and a file within a directory2 we need to use a chgrp's 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

Share this linux post:

Submit chgrp in Delicious Submit chgrp in Digg Submit chgrp in FaceBook Submit chgrp in Google Bookmarks Submit chgrp in Stumbleupon Submit chgrp in Technorati Submit chgrp in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download