Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Location
    WHT, where else?
    Posts
    420

    how to change ownership and group for a batch of files/directories?

    I've untar-ed a .tar.gz file on my vps using a linux command line. But now the ownership and group of those files/directories need to changed. It would be very painful if changing them one by one, because I have many subdirectories and thousands of files under them. I was wondering if there is any commands such as chown out there I can use to change the ownership and group simultaneously?

    appreciate your help.

    thanks

    IVYtony
    Tubenode.com - FFMPEG, PHP & RoR Hosting
    RCholic.com - R/C videos sharing

  2. #2
    You can run:

    chown -R user:group directory

    to change user and group ownership of the directory and all its files / subdirectories
    KnownHost Linux VPS Specialists
    Toll Free: (866)-785-5479
    www.knownhost.com sales@knownhost.com

    New look & New plans!

  3. #3
    Join Date
    Jul 2001
    Location
    Canada
    Posts
    1,284
    If you have for example a directory called newfiles with files and subdirs to be changed to user john in the aliens group the following is what you would use:

    chown -hR john:aliens newfiles/

    the R means to recurse through files and subdirectories
    the h means to only change ownership of symlinks, not the files/directories they point to

    check out "man chown" or "info chown" at your shell prompt for further info.
    "Obsolesence is just a lack of imagination."

  4. #4
    Join Date
    Jan 2005
    Location
    WHT, where else?
    Posts
    420
    Quote Originally Posted by NyteOwl
    If you have for example a directory called newfiles with files and subdirs to be changed to user john in the aliens group the following is what you would use:

    chown -hR john:aliens newfiles/

    the R means to recurse through files and subdirectories
    the h means to only change ownership of symlinks, not the files/directories they point to

    check out "man chown" or "info chown" at your shell prompt for further info.
    thanks, it worked like magic. But it seems to change the ownership only. i.e. the group was not changed. any modifications?

    thank you guys so much!
    Tubenode.com - FFMPEG, PHP & RoR Hosting
    RCholic.com - R/C videos sharing

  5. #5
    Join Date
    Jan 2005
    Location
    WHT, where else?
    Posts
    420
    never mind. I tried this command to change the group:

    chgrp -R ivytony directory
    and this worked as well!

    Thank you so much
    Tubenode.com - FFMPEG, PHP & RoR Hosting
    RCholic.com - R/C videos sharing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •