Recursively Change the Group Owning a Directory


chgrp -R

Of course, you might not want to change the group of just one file or directory. If you want to change the groups of several files in a directory, you can use a wildcard. If you want to change the contents of a directory and everything below it, use the -R (or --recursive) option.

$ pwd /home/scott/pictures/libby $ ls -F by_pool/  libby_arrowrock.jpg libby.jpg on_floor/ $ ls -lF * -rw-r--r-- 1 scott scott ... libby_arrowrock.jpg -rw-r--r-- 1 scott scott ... libby.jpg by_pool/: -rw-r--r-- 1 scott scott ... libby_by_pool_02.jpg drwxr-xr-x 2 scott scott ... lieberman_pool on_floor/: -rw-r--r-- 1 scott scott ... libby_on_floor_01.jpg -rw-r--r-- 1 scott scott ... libby_on_floor_02.jpg $ chgrp -R family */* $ ls -l * -rw-r--r-- 1 scott family ... libby_arrowrock.jpg -rw-r--r-- 1 scott family ... libby.jpg by_pool: -rw-r--r-- 1 scott family ... libby_by_pool_02.jpg drwxr-xr-x 2 scott family ... lieberman_pool on_floor: -rw-r--r-- 1 scott family ... libby_on_floor_01.jpg -rw-r--r-- 1 scott family ... libby_on_floor_02.jpg 


Caution

If you used chgrp -R family *, you wouldn't change any of the dot files in the /home/scott/pictures/libby directory. However, chgrp -R family .* should not be used. It changes all the dot files in the current directory, but .* also matches .., so all the files in the parent directory are also changed, which is probably not what you want!




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net