Common commands for CentOS permission management

Source: Internet
Author: User
Summary of linux file permission management! (4W1H mode) 1. for example (. 1) you are familiar with this figure. let's talk about permission management! 2. for file types and permissions, let's take a look at Section 1.1. let's take a look at Column 1. file types :&

Summary of linux file permission management! (4W1H mode)

1. for example

(. 1)

You are familiar with this figure. let's talk about permission management!

2. file types and permissions

Let's take a look at section 1.1 first. let's look at the first column,

File type:
-: Common File (f)
D: directory file
B: block device files)
C: character device file (character)
L: symbolic link file)
P: Command pipeline File (pipe)
S: socket file)


File permission:

A total of 9 bits, each with three bits, each with rwx (read, write, and execute). For example, the permission of the message file is rw-r --

As we have mentioned above, the permissions of files are divided into three groups. what do these three groups represent?

Group 1: file owner permissions

Group 2: permissions of the group to which the file belongs

Group 3: permissions of other users

Now we know that there are three groups of file permissions: you can set rwx (read, write, and execute), so let's take a look at what commands can be used to set these permissions and attributes!

3. permission-related commands

  • Chown: change the file owner

  • Chgrp: change the group to which the file belongs

  • Chmod: changes the file permissions, SUID, SGID, SBIT, and other features

(1). chown

Chown [-R] account name: group name file or directory options and parameters:

-R: perform recursive changes, that is, all files under the Directory are changed.

For example, chown root install. log


(2). chgrp

Chgrp [-R] dirname/filename... options and parameters:

-R: perform recursive changes, that is, update all files and directories under the sub-directory to the group.

Example: chgrp test install. log

Note: chown root: root install. log can change the file owner and group (#:#)


(3). chmod

Chmod [-R] xyz file or directory options and parameters:

Xyz: The permission attribute of the numeric type just mentioned. it is the sum of the values of the rwx attribute.

-R: perform recursive changes, that is, all files under the directory will be changed together.

A. change the file permission for the numeric type.


There are nine basic permissions for Linux files: owner, group, and others. Each of these three identities has its own read, write, and execute permissions ,. 1: The permission character of the file message is rw-r --. the nine permissions are set by three or three! Here, we can use numbers to represent each permission. the score of each permission is as follows:

R: 4
W: 2
X: 1
The three permissions (r/w/x) of each identity (owner/group/others) must be Accumulated. 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 change the permission settings, the permission number for this file is 770!

Chmod 770 message


B. change the file permission of the symbol type

There is another way to change permissions! From the previous introduction, we can find that the nine permissions are (1) user (2) group (3) others! Then we can use u, g, o to represent the permissions of three identities! In addition, a represents all, that is, all identities! Then the read and write permissions can be written as r, w, x! That is, you can use the following method:

Chmod

U
G
O
A

+ (Join)
-()
= (Set)

R
W
X

File or directory


For example, if we want to set the permission for a file to-rwxr-xr-x, it is basically:

  • User (u): Has the readable, writable, and executable permissions;

  • Group and others (g/o): have the permission to read and execute.

Chmod u = rwx, go = rx message

After the above explanation, let's talk about the basic management of file permissions! Do you understand? Hey, next article, let's talk about Linux user management!

This article is from "Share your knowledge ..." Blog, please be sure to keep this source http://freeloda.blog.51cto.com/2033581/1206739

Related Article

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.