Linux file permissions detailed

Source: Internet
Author: User
Tags readable

everything in Linux is file, so files are important, file properties and how to change properties.

to view the properties of a file:

The owner of the file is divided into owners, owning groups, and others.

after logging in as root , you can use ls-al to list details of all files, including hidden files ( that is, the first file name is a character . begins with ),

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/86/59/wKiom1e8f-PSz-o9AAGOli0qJRM467.png-wh_500x0-wm_3 -wmp_4-s_2549750515.png "style=" Float:none; "title=" 1.png "alt=" Wkiom1e8f-psz-o9aagoli0qjrm467.png-wh_50 "/>


each row from left to right, the first line is made up of ten letters, and the first letter represents the file attributes, such as

D indicates directory

- Presentation file

L Indicates the connection file

B represents an interface device that is available for storage in the appliance file

C indicates the serial port device in the appliance file

The next string, grouped into three groups, is divided into three groups. The first group represents the execution rights of the owner,rwx is readable, writable, operable, and if no corresponding permission is written in that place - representation. The second group, the third group, respectively, the group, other permissions.

The number in the second column indicates how many files are connected to this top

In the third column, the fourth column indicates the owner account of the file and the account number of the owning group respectively.

Column Five indicates the size of this file, which defaults to byte

Column six indicates the date the file was last modified.

The seventh column indicates the name of the file

to change the properties of a file:

CHGRP: Changing the owning group of a file

Chown: Changing the owner of a file

Chmod: Changing the permissions of a file

1.CHGRP + target group + changed files

The following group of . Bash Logout is changed from root to Tom

650) this.width=650; "Width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ( "/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>650) this.width=650; "Src=" http://s5.51cto.com/wyfs02/M00/86/58/wKioL1e8f-TTuqlpAABLAOwoDiw485.png-wh_500x0-wm_3-wmp _4-s_3747310735.png "title=" Picture 2.png "style=" Float:none; "alt=" wkiol1e8f-ttuqlpaablaowodiw485.png-wh_50 "/>

650) this.width=650; "Width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ( "/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>

Change owner:

Chown [-R] + target owner's name + file name

Plus- R will change the owner of all files under the same directory;

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/86/59/wKiom1e8f-WiuMKYAAA9Wc6fQ4s988.png-wh_500x0-wm_3 -wmp_4-s_2491393875.png "style=" Float:none; "title=" Picture 3.png "alt=" Wkiom1e8f-wiumkyaaa9wc6fq4s988.png-wh_50 "/>

Change both the owner and the owning group:

Chown + Target owner name: Name of the group to which the target belongs + file name

Ri

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/86/58/wKioL1e8f-uB5zEmAAA1W0osGts790.png-wh_500x0-wm_3 -wmp_4-s_3256384181.png "title=" Picture 6.png "style=" Float:none; "alt=" Wkiol1e8f-ub5zemaaa1w0osgts790.png-wh_50 "/> 650) this.width=650; "Width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ( "/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd; "alt=" Spacer.gif "/>

Change permissions:

How to change permissions: Change by number

Rwx represents 421 respectively.

Chmod + three digits + file name

Chmod 777 Tom

is to change All three of Tom's files to a readable and writable executable.

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/86/58/wKioL1e8f-eCUFDTAADjeeue9H4159.png-wh_500x0-wm_3 -wmp_4-s_216662876.png "title=" Picture 4.png "style=" Float:none; "alt=" Wkiol1e8f-ecufdtaadjeeue9h4159.png-wh_50 "/>  

There's another way:

CHOMD u/g/o/a +/-/= rwx file name

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/86/59/wKiom1e8f-uhy6LbAAGOli0qJRM544.png-wh_500x0-wm_3 -wmp_4-s_980398718.png "title=" Picture 5.png "style=" Float:none; "alt=" Wkiom1e8f-uhy6lbaagoli0qjrm544.png-wh_50 "/>  

This method can be used to change a permission but not the original permission.

permission meanings for directories and files

The importance of permissions to files:

R: Can read the actual contents of the file

W: Can edit new or modify file contents

X: The file can be executed by the system permissions, the file can be executed is determined by the permission to have X , and the file name does not have an absolute relationship

When you have w permission on a file . Can be written to edit this file but does not have the ability to delete. For file rwx , it is mainly for " file content ", regardless of the existence of the filename. The file records the actual data.

The importance of permissions to the directory:

The file is where the data is stored, and the directory is where the file name is stored.

R: represents a permission to read a list of directory files , which means you can query the list of data in this directory when you have r permission

W: You can change the permissions of the data list, which can be categorized as follows:

1. Create a new file and directory

2. Deleting files

3. Renaming

4. transfer files in this directory, directory location

X: User can enter the directory to become the working directory for the purpose


Linux file permissions detailed

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.