The use of Linux chgrp chown chmod __linux

Source: Internet
Author: User
Tags chmod

We know that file permissions for a system security importance, but also know the file permissions for users and groups of relevance, then how to modify the attributes and permissions of a file.

Here are a few instructions that are commonly used for groups, owners, and permissions for various identities. As shown below:

CHGRP: Changing the file-owning group (English explanation: Change group)

Chown: Changing file Owner (English explanation: Change owner)

chmod: Changes in file permissions, SUID, SGID, sbit and so on characteristics (English explanation: Change mode)

1. Change the group that belongs, CHGRP


Options and Parameters:
-r: Continuous changes to recursive (recursive), that is, all files and directories under the secondary directory are updated to the meaning of this group. Often used to change the status of all files in a directory.
Example:




Chgrp:invalid group name ' testing ' <== error message I can't find this group name ~

2. Change the owner of the file, Chown

[Root@www ~]# Chown [r] Account name file or directory 
[root@www ~]# Chown [-r] Account name: Group name file or directory
options and Parameters:- 
   R: Continuous change of recursion (recursive), i.e. Along with all the files in the secondary directory change

paradigm: Change the owner of the Install.log to bin this account:
[root@www ~]# Chown bin Install.log 

-rw-r--r--1 bin users 68495 June 08:53 Install.log Example: Change the owner and group of the Install.log back to root: [root@www, ~]# chown Root:roo T Install.log
-rw-r--r--1 root root 68495 June 08:53 Install.log

3. Change of authority, chmod

There are two ways to set permissions, and you can use numbers or symbols to change permissions.

3.1 Number types Change file permissions

Linux files have the basic permissions of nine, respectively, owner/group/others three identities have their own Read/write/execute permissions

For example: File permissions characters are-rwxrwxrwx these nine permissions are three three sets. In which, we can use numbers to represent the various permissions, the score table for each authority is as follows:

R:4 W:2 x:1

Each of the three permissions (r/w/x) points for each identity (owner/group/others) needs to be cumulative, for example when the permission is: [-rwxrwx---] the score is:

Owner = rwx = 4+2+1 = 7

Group = RWX = 4+2+1 = 7

others=---= 0+0+0 = 0

So when we set permission changes, the number of permissions for that file is 770. Instructions for changing permissions The syntax for chmod is this:

[Root@www ~]# chmod [-r] XYZ file or directory 
options and Parameters: 
XYZ: is the permission attribute of the numeric type just mentioned, the addition of the RWX attribute value. - 
R: Continuous changes to recursive (recursive), i.e. all files in the secondary directory will be changed

For example, if you want to have all of the permissions on the BASHRC file enabled, then release:





-rwxrwxrwx 1 root root 395 June 4 11:45. BASHRC

What if you want to turn the authority into-rwxr-xr--? Then the privilege score becomes [4+2+1][4+0+1][4+0+0]=754. So you need to release:

[root@www ~]# chmod 754 filename

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.