How do I change my files to be owned by another unix group?



  • To check to see if you are in a certain unix group, use the commands id or groups. To change the group of a file or directory you need to be in the group, you want to change files or directory to, for example let's say you want to change the group of the file called afile, from the unixbod group to the sysadmin group, use chgrp command as follows:
    Original file in the unixbod group

    [unixbod@venus ~]$ ls -l
    total 12
    -rw-rw-r−− 1 unixbod unixbod 0 Sep 21 21:46 afile
    

    Use chgrp to change the group

    [unixbod@venus ~]$ chgrp sysadmin afile
    

    Confirm the change

    [unixbod@venus ~]$ ls -l
    total 12
    -rw-rw-r−− 1 unixbod sysadmin 0 Sep 21 21:46 afile
    

    NOTE: One, you have to be in the unix group to be allowed to change groups, and two, if you were added to the unix group while you were logged in, only the next time you log in will you be able to change the group.
    TIP: The chgrp command has a -R option to recursively change group ownerships, for instance changing the group of a directory and all the files under it.


Log in to reply
 

© Lightnetics 2024