Linux Basics-Rights Management commands Chown, CHGRP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.