Using chgrp


Using chgrp

Although you can't change a file's owner, you can change the group that a file belongs to. You can do this with the chgrp command. chgrp is a Unix command used to change the group setting. The chgrp command stands for "change group." The chgrp command marks a file as being part of a different group. To do this, however, you must be a member of that group. Your Unix system administrator has the capability to create new groups and add users to these groups. If you have any questions about your own group membership(s), ask your administrator how your account was configured.

To use chgrp, follow these steps:

1.

Choose the file or files you want to change.

2.

Determine which group the file now belongs to.

3.

Change the file's group using the following command: chgrp <new group> <filename> <filename> ....

For example, type the following:

 >chgrp admins script.sh >ls -lg script.sh -rwxr-xr-x 1 rob admins 1463882 Dec 25 12:00 (output removed) 

The script.sh file now belongs to the group admins. Members of the group have read and execute permissions for the file. The most obvious use for chgrp is if you are collaborating on a project. If you create a file that you want to share with many people, you'll need to change the group of the file to one that all the users belong to.

Be Careful with What You Change Be careful when setting permissions. If you change something too drastically, you can really get into trouble. Changing permissions can also lock you out of something, so be careful using this lesson in a production environment if you are just learning Unix. Consider what can happen, for the worse.




    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

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