Linux File Permission, linux permission

Source: Internet
Author: User
Tags website server

Linux File Permission, linux permission
Permission deny Permission drop view Permission ls-a ls-la expression view Permission of the folder

  • Classification group of user groups: an operating system may be used by several people to facilitate the security and sharing of group files.
User Group (in a group) Others root rws tianshen user/root information is recorded in /Etc/passwdThe password is recorded in /Etc/ ShadowFile rwx 4r 2 w 1x
  • 1. For Files
1. in Windows, the suffix of a file is similar to .exe. bat is an executable file, but it is not directly related to the file Suffix in Linux, as long as it is x, it can be executed 2. another point is that w focuses on content modification, just like FileIn/OutputStream. It cannot delete files.
  • 2. For the Directory
R --- you can view the content w ---- you can move the File in it at will/delete it is OK, so w serves as the IO File role x in the File and directory respectively --- can it become a job? the directory working directory is the directory of the current terminal. That is to say, the directory is working on a terminal.

 
  • Connections
  • For a file, its permission attributes are written in the file system I-node.
  • The number of connections is the number of related files (not the number of files in the directory tree)

 

Time is the last modification time ls -- full view ls help documentation: man lsinfo ls Example 1: Suppose test1, test2, test3 belong to the group testgroup, if there are two files below, what are the permissions related to the owner of the two files? -Rw-r -- 1 root 238 Jun 18 test.txt-rwxr-xr -- 1 test1 testgroup 5238 Jun 19 ping_tsai 1. if it belongs to the root user, all of them are Others. Only read2. test1 rwx can be OK test2/test3 rxOK and can be read and executed by other users (persons not in the group to which the file belongs) r is read-only (including root) example 2: If my directory is under the style, can the members of The testgroup group and other people (others) access this directory? Drwxr-xr -- 1 test1 testgroup 5238 Jun 19 groups/test1 rwx OKtestgroup the people in the group can only [r-x] into this directory, but cannot be written to other users. Only r can be read. what is in this directory but cannot be included (x) cannot Write (w)
  • Summary
  • For the directory r --- you can check what is in it
  • W ----- It is equivalent to creating or deleting a File in a File object.
  • X ------ you can enter
  • To change the file attributes and permissions, you must use the root user.
The following three commands change the chgrp file group chown to change the chmod permission of the own file owner.

-All files under R are changed. separate usernames. the group name can be used to modify two attributes at the same time, but if you like to add a decimal point to the account, this will result in system misjudgment and know how to change the group and owner of the file, so when will chown or chgrp be used? Maybe you think it's strange? Yes, sometimes it is necessary to change the owner of a file. The most common example is to use the simplest cp command to explain when copying a file to someone other than you:
[Root @ www ~] # Cp
Suppose you want to copy the. bashrc file to the. bashrc_test file today and give it to the bin user. You can do this:
[Root @ www ~] # Cp. bashrc. bashrc_test [root @ www ~] # Ls-al. bashrc *-rw-r -- 1 root 395 Jul 4 11: 45. bashrc-rw-r -- 1 root 395 Jul 13 11: 31. bashrc_test <= the attributes of the new file remain unchanged.
Because the copy action (cp) will copy the attributes and permissions of the performer, so! What should I do ?. Bashrc_test is owned by the root user. As a result, even if you give the file to the bin user, it still cannot be modified (you can see the attributes/permissions ), so you must modify the owner and group of the file! Do you know how to modify it?

This third method is used to make minor changes. Many people are stuck in some permission settings when they are on the shelf. For example, if they want to open data to users, they only need to open the r permission, this causes the website server to be unable to view the directory. It can only be viewed outside the document (r. [R-x] but note that the permissions of r-x are very important to the user. The w permission cannot be used as an example: assume that an account is named dmtsai, his home directory is in/home/dmtsai/, and dmtsai has the permission to [rwx] This directory. If there is a file named the_root.data in this directory, the permission for this file is as follows:-rwx ------ 1 root 4365 Sep 19 the_root.data. What is the permission of dmtsai for this file? Can I delete this file? A: dmtsai belongs to others and cannot read or modify the file. It cannot be executed to check whether a file can be deleted. Check whether the user has the permissions of w at the upper level, here, dmtsai has the rwx permission on the dmtsai/directory, that is, it can delete or add all files in this directory w Review:In each file in Linux, permissions are divided into three identities: users, groups, and others. One of the most useful features of a group is that when you develop resources in a team, each account can support multiple groups 『. ", indicates that the file is" hidden file ". The group that changed the file supports chgrp, and the owner of the file can use chown, you can use chmodchmod to modify the File Permission in two ways: the symbol method and the number method. The r, w, and x scores in the number method are 4, 2, and 1. the symbol method: ug = wx, o = r There is also a small Method for modification: a + w, u-r, o + x, g-w for files, the efficiency of permissions is:
  • R: You can read the actual content of the file, such as the text content of the text file;
  • W: You can edit, add, or modify the content of the file (but not delete the file );
  • X: the file can be executed by the system.
For the directory, the permission efficiency is:
  • R (read contents in directory)
  • W (modify contents of directory)
  • X (access directory)
To open a directory for anyone to browse, at least r and x permissions should be given, but w permissions cannot be given at will;

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.