chgrp command
LINUX-Frequently used commands
chgrp command Change the group of the file |
Syntax |
chgrp [Group] file-name |
The chgrp command changes the group of a file to the specified group. The group can be specified by name or by ID, and the file will automatically belong to the group to which the user who created the file belongs. The file will automatically belong to the group to which the user who created the file belongs. The chgrp command can also be executed by ordinary users, but they can only modify the file when it is The chgrp command can also be executed by ordinary users, but ordinary users can only modify the file if they are the owner of the file. The chgrp command can also be run by a regular user, but the regular user can only modify the file if the user is the owner of the file. the group to which the user belongs. Since a user can belong to multiple groups, you can use the chgrp command to make a file belong to another group to which it belongs. If you are running the chgrp command as a super user (root), you can use the chgrp command. If you run the chgrp command as a super user (root), you can handle files owned by any user. If you run the chgrp command as the super user (root), you can handle files owned by any user and change them to any group. |
Frequently used options |
-R Change the group affiliation of a directory and the files in it -f Don't show error message if some files could not be changed to a different group. |
Example: Change the group of the file. |
$ su - ← Become roott passwd ← Enter root password. # chgrp root /tmp/temp.txt ←Set the group of the file "temp.txt" to root # ls -l /tmp/temp.txt -rw-rw-r-- 1 koro root 0 Jan 01 01:01 temp.txt ← The group you belong to will be root |