I. Chown command and the function of the CHGRP command
Sometimes you need to change the owner of a file or directory, such as a person leaving or a developer creating an application that needs to belong to a system account in a test or production environment. Linux provides two commands to implement this function: The Chown command is used to change the owner of the file, and the Chgrp command is used to change the default genus of the file.
ii. syntax of the chown command and the CHGRP command
chown command syntax: Chown owner file
CHGRP command syntax: CHGRP Group file
Owner: The specified owner or UID, which is the new owner.
Group: The specified owning groups, that is, the new owning group.
File: The specified files or directories.
Three, the effect demonstration
Create a 55555.txt file in the temp directory, and then view the default owner and owning group for the file, as shown in the Linux command in effect 3-1.
1 Touch 55555 . txt 2 ls 55555. txt
Figure 3-1
As can be seen from Figure 3-1, the default owner of the 55555.txt file and the owning group are CentOS, the next step is to change the 55555.txt file owner and owning group, but the current logged on user must have permission to change
The owner of the file and the owning group, so switch the root user to change.
First change the 55555.txt file owner, the Linux command as shown in effect 3-2.
1 Chown 55555. txt
Figure 3-2
Furthermore, to change the owning group of the 55555.txt file, the Linux command is as follows, as shown in effect 3-3.
1 chgrp 55555. txt
Figure 3-3
Finally, this is also true for the owner and group of the directory that changed.
Linux Basics-Rights Management commands Chown, CHGRP