chgrp - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

chgrp - change group ownership

SYNOPSIS

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

DESCRIPTION

Change the group of each FILE to GROUP. With --reference, change the group of each FILE to that of RFILE.

OPTIONS

TAG DESCRIPTION
-c, --changes like verbose but report only when a change is made
--dereference affect the referent of each symbolic link (this is the default), rather than the symbolic link itself
-h, --no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink)
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
-f, --silent, --quiet suppress most error messages
--reference=RFILE use RFILE's group rather than specifying a GROUP value
-R, --recursive operate on files and directories recursively
-v, --verbose output a diagnostic for every file processed

EXAMPLES

EXAMPLE-1:

 Change the owning group of the file system_proc_1 to the group named test.

Before changing group verify with which group it is associated by 

$ ls -l system_proc_1

-rw-rw-r-- 1 nubo nubo 3050 Jan  7 13:30 system_proc_1

# chgrp test  system_proc_1 
or
$ sudo chgrp test  system_proc_1

output:
ls -l system_proc_1

-rw-rw-r-- 1 nubo test 3050 Jan 7 13:30 system_proc_1

EXAMPLE-2:

To give access permissions to a command:

(so that the command can be executed by all users belonging to nubo )

$ chgrp nubo /etc/init.d/httpd

EXAMPLE-3:

To change group ownership  of all the files located in home/nubo to group:nubo

chgrp -R nubo /home/nubo

output:
ls -l
total 116
-rw-rw-r-- 1 nubo nubo 55 Jan 5 21:28 actions.txt.bz2
drwxrwxr-x 6 nubo nubo 4096 Dec 7 22:03 Applications
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Desktop
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Documents
drwxr-xr-x 2 nubo nubo 4096 Nov 30 00:18 Downloads
-rw-r--r-- 1 nubo nubo 8980 Nov 29 22:18 examples.desktop
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Music

EXAMPLE-4:

To change group ownership forcefully:

chgrp -f nubo /home/nubo

output:
ls -l
total 116
-rw-rw-r-- 1 nubo nubo 55 Jan 5 21:28 actions.txt.bz2
drwxrwxr-x 6 nubo nubo 4096 Dec 7 22:03 Applications
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Desktop
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Documents
drwxr-xr-x 2 nubo nubo 4096 Nov 30 00:18 Downloads
-rw-r--r-- 1 nubo nubo 8980 Nov 29 22:18 examples.desktop
drwxr-xr-x 2 nubo nubo 4096 Nov 29 23:13 Music

Previous Page
Next Page