Linux Basic operations----Rights Management

Source: Internet
Author: User

Linux has this powerful permission to operate. We can simply classify Linux rights management:


The permissions themselves are : Read read , write wRite , run execute

Permissions for Target: file, folder folder

Permissions for users: master user, same group group, other group oTher


We now give a sample to explain the above:

current user is zhoudong 

zhoudong (music)

rwx (Master privilege: Read/write/Run)

doublegun.txt

Xueyou (music)

rw-(same group User rights: Read/write)

doublegun.txt

< /span>xiaogang (movie)

r-(other group User rights: Read)

doublegun.txt

Then Zhoudong is the owner of the file, but also the music circle of people, then can have the Doublegun.txt file read, write, run operations.

Zhoudong and xueyou are all music circles, so xueyou belong to the same group of users. Xiaogang is a movie, so for Zhoudong. Is the other group of users


1. permission set operation: chmod directive ------------ contains +,-

① Set permissions in relative ways ( permissions without actions are not affected )

> chmodu+rwx filename//Add read, write, and run permissions to the file "owner"

> chmod g+rwx filename//Add read, write, and run permissions to the file "same group of users"

> chmod o+rwx filename//Add read, write, and run permissions to the file "other group users"

> chmodu+rwx,g+rwx,o+rwx filename

> chmodu-rwx,g-rwx,o-rwx filename//Remove the permissions of the appropriate user for the file

> chmodu-w,u+r filename//Add a "R read" permission to the file owner. Lower the "W write" permission at the same time

(This is not a good way to set a situation where permissions vary greatly: for example, only one permission is reserved, only the R permissions of other group users)


② Digital Absolute Way Set permissions

Read:4 write:2execute:1

0: None

1: Run

2: Write

3: Write, run

4: Read

5: Read, run

6: Read and Write

7: Read, write, run


chmod ABC filename

ABC represents the owner, the same group, the other group user rights respectively

> chmod 541 filename//Master

Set permissions for numbers and letters select: The change of permission settings is larger choose to use the "digital Absolute" permission settings change smaller select Use "Letter Relative Way"


2. Use of permissions

use of ① files for permissions

Read : Ability to view information inside a file

Write: have permission to edit file contents

Run: Ability to put a lot of system-related instructions into a file side, set the file to run, so that once

Sex runs a lot of instructions (with batch effects)----go straight to/bin/sbin/usr/bin/usr/sbin once to find

Make a "shell script" file that includes many instructions.

Attention:

If the user has no file read , write rights, the file does not agree to change, but we can forcibly write the save.

① Current User is the owner of the file, even if there is no right to read or write. can also forcibly write save.

② Other users have no write-save rights to the file, can also forcibly write the save (affecting the owner of the file, and the group changes) the file's parent folder for the user has w write rights.

③ Other users do not have write-save rights to the file. It is not enough to write and save forcibly.

The reason is that the file has no W write rights for the user, and the file's parent folder does not have a w write right for that user.

you want to save the file for a folder. To disable certain user actions, set the appropriate permissions on the file's corresponding folder. folder is not read for this user Read , write Write , Run execute permissions. this way the user does not have any permissions on the folder's files .

Use of ② folder for permissions

READ: Can see the file information inside the folder

Write : Do you have permission to create and delete level two files within the folder, and to create and delete level two folders?

run : Do you have the right to switch the CD into the folder


Linux Basic operations----Rights Management

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.