Linux Learning Notes (11)--Command Learning (file permission properties)

Source: Internet
Author: User

Before we begin our new content study, we will briefly review the above content:


      absolute path: "must be the root directory/write"; Relative path: "Not/write"

    1. special directory:.,..,-, ~, ~ Account needs to be noted;

    2. rmdir can only delete empty directories, the "rm-r" command is required to delete a non-empty directory;

    3. file copy, delete, move can be used separately: CP, RM, MV and other commands to operate;

    4. The commands that you can use to check the contents of a file include: Cat, TAC, NL, more, less, head, tail, OD, etc.

      /li>
    5. cat-n and NL can display line numbers, but by default, blank lines will not be numbered;

    6. Span style= "Color:rgb (0,112,192);" The purpose of >touch is to modify the time parameters of the file, but can also be used to create an empty file;  

Linux File Permission Properties command

The file attributes we mentioned here are actually similar to the right-click >> properties in Windows, where you can see the types of files, the groups they belong to, the people they belong to, the setting time, permissions, and so on. However, since Linux is primarily used in the CLI, it is necessary to recognize the relevant commands.

But before we learn to use commands, we also need to know about Linux properties:

1, how to check the file permissions properties, which contains the content??

Ls-l

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/33/wKiom1Q4vzbxtSa2AAPa7Nyt7rQ573.jpg "title=" 1.png " Width= "654" height= "217" border= "0" hspace= "0" vspace= "0" style= "WIDTH:654PX;HEIGHT:217PX;" alt= " Wkiom1q4vzbxtsa2aapa7nyt7rq573.jpg "/>

The red box above is the file's properties. There are file types, owning group, owning member, file size, creation time date, and so on.

Specifically what that means, see the following file attributes:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/34/wKioL1Q4xbOhMVFJAAERZRNtTxs182.jpg "title=" 2.png " alt= "Wkiol1q4xbohmvfjaaerzrnttxs182.jpg"/>

One of the main things we do know is the previous section (the permission section), which is divided into four parts.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/35/wKioL1Q4y5SjzhDuAAGjWRlT6jU391.jpg "title=" 3.png " Width= "622" height= "166" border= "0" hspace= "0" vspace= "0" style= "width:622px;height:166px;" alt= " Wkiol1q4y5sjzhduaagjwrlt6ju391.jpg "/>

A, the first part of the expression: file type

[d] is the directory

[-] is the file

[l] means the link file (link file);

[b] means the storage interface device (optional random access device) inside the device file;

[C] is the device file inside the serial port device, example keyboard, mouse (disposable reading device).


B, 第二、三、四部 Sub-details such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/37/wKioL1Q47ADhfEppAAIZBtrm2mk373.jpg "title=" 4.png " Width= "622" height= "157" border= "0" hspace= "0" vspace= "0" style= "WIDTH:622PX;HEIGHT:157PX;" alt= " Wkiol1q47adhfeppaaizbtrm2mk373.jpg "/>

2, now we will look at the above content, but also know the meaning of the various parts to express, but the above letter (R W X) is what meaning???

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/36/wKiom1Q48lPjEeLoAAI_sPOEU90438.jpg "title=" 5.png " Width= "622" height= "211" border= "0" hspace= "0" vspace= "0" style= "width:622px;height:211px;" alt= "Wkiom1q48lpjeeloaai _spoeu90438.jpg "/>

Through the above study, we already know what these above means, so we now have to do the command of learning, through the command of learning, we will be on the above related properties to make changes and adjustments.

Because the following command is to use root or a user with administrator privileges to operate, and to have two users at the same time, here I do not create an administrator, directly using root to operate, but because now there is only one user (Hznethome) in the system, So we're going to create a user (by default in Linux, create a user, and it will create a group with that user.) Below we start to create user, add password and so on.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/36/wKiom1Q4_P_CzGfSAAM7FYiw0YM827.jpg "title=" 6.png " Width= "622" height= "254" border= "0" hspace= "0" vspace= "0" style= "width:622px;height:254px;" alt= "Wkiom1q4_p_ Czgfsaam7fyiw0ym827.jpg "/>


Chown chmod chgrp chattr lsattr umask Command Learning


Command Chown (change owner abbreviation for English)
Function Literally understand that we know that chown is changing the user's right to have access to the meaning
Grammar Chown "parameter" "owner" "file name to make changes"
Extended -R: If you want the files below the directory to be recursively changed to this permission, use the parameter R
Instance

1, the following we put Hznethome users in the/tmp/blog/hznethome in a test.txt file has the rights to change to Hz users.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/36/wKiom1Q4_nnDPRalAAJ7-41LgMo156.jpg "title=" 7.png " Width= "622" height= "179" border= "0" hspace= "0" vspace= "0" style= "WIDTH:622PX;HEIGHT:179PX;" alt= "wkiom1q4_ Nndpralaaj7-41lgmo156.jpg "/>

2. If we want to change all the files at once to Hz to Woner, we will use the parameter R mentioned above, for example, I want to change all the files in Hznethome to the user Hz owner.

Test environment:/tmp/blog/hznethome has Hz net home and Test.txt, where there is a hz.txt file in the Hz folder, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/39/wKioL1Q5HW_SNyIXAAFO2j55KRE486.jpg "title=" 8.png " Width= "622" height= "260" border= "0" hspace= "0" vspace= "0" style= "width:622px;height:260px;" alt= "Wkiol1q5hw_ Snyixaafo2j55kre486.jpg "/>

Well, let's check out who they are now, and make comparisons. As you can see in the diagram, all the owners are hznethome users.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/39/wKioL1Q5HtfC1lA4AAMizm_Qg6s108.jpg "title=" 9.png " Width= "622" height= "176" border= "0" hspace= "0" vspace= "0" style= "width:622px;height:176px;" alt= " Wkiol1q5htfc1la4aamizm_qg6s108.jpg "/>

The environment is set up, we start the above operation, using the parameter-R to the Hznethome file ownership is changed to Hz users.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/39/wKioL1Q5IGDSr1p6AAYEpYI0QBE466.jpg "title=" 10.png "Width=" 622 "height=" 298 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:298px; "alt=" Wkiol1q5igdsr1p6aayepyi0qbe466.jpg "/>


Command chmod (abbreviation for Change model English)
Grammar chmod "Parameters" XYZ file or document name to change
Function Change file permissions
Extended

1, XYZ respectively for each group of RWZ Plus and

such as: X=r+w+z y=r+w+z z=r+w+z

2,-R recursive change, the same as the use of the above chown

Instance

1. Now we change the Test.txt file permissions in Hznethome to 777

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/39/wKioL1Q5IwuyRH-gAAH1qhU6Umc824.jpg "title=" 11.png "Width=" 622 "height=" 117 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:117PX; "alt=" Wkiol1q5iwuyrh-gaah1qhu6umc824.jpg "/>

2, now we put Hznethome user established/tmp/blog/hznethome in the file permissions to change to 777.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/37/wKiom1Q5JCjTe5hEAAZHN8I5z9E277.jpg "title=" 12.png "Width=" 622 "height=" 407 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:407PX; "alt=" Wkiom1q5jcjte5heaazhn8i5z9e277.jpg "/>

3, we can also use the following way to change the permissions of the file.

Below will refer to a picture on the internet to illustrate this, I do not test here, interested can go back to test themselves. The picture source hope does not cause the copyright question, ha ...

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/38/wKiom1Q5JbCj4PFnAAOeULO8g3U746.jpg "title=" 13.png "Width=" 622 "height=" 532 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:532px; "alt=" Wkiom1q5jbcj4pfnaaoeulo8g3u746.jpg "/>


Command CHGRP (change group English abbreviation)
Grammar Chgrp
Function
Extended
Instance


Command CHGRP (change group English abbreviation)
Grammar
Function
Extended
Instance


Command CHGRP (change group English abbreviation)
Grammar
Function
Extended
Instance


chattr (Profile Hide Property )

Lsattr (show file hidden properties)

Modify file Properties Chgrp: Change the file belongs to the group file default permissions: Umask


Connection file

Soft

Hard


This article is from the "Last Bus" blog, so be sure to keep this source http://hznethome.blog.51cto.com/722914/1562605

Linux Learning Notes (11)--Command Learning (file permission properties)

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.