Linux file permissions

Source: Internet
Author: User

PermissionDeny permission denied View Permissionsls-aLs-la expression View permissions for something inside a folder
    • Classification Group of user groups: an operating system may be used by several people at the same time with convenient group file security and sharing
User group (inside a group) Others root RWS RWS RWS Tenjininformation about the user/root is recorded under /etc/passwd The personal password is recorded under the /etc/ Shadow file rwx 4r 2w 1x
    • 1. For file
1. Windows see a file suffix such as. exe. BAT is an executable fileHowever , there is no direct relationship between Linux and the file suffix , as long as x can be executed 2. Also note that this W focus on content modification is like Filein/outputstream It is not possible to delete files
    • 2. For directory
R---Can see what's inside.W----You can move the file in the inside/delete also OKso for W in the files and directories respectively Act as role of IO File x---can be a working directory The working directory is the directory where the current terminal resides . That means the terminal is working in this directory.

    • Number of connections
    • For a file, its permission properties are written in the file system I-node node
    • For the directory tree is the name of the frontier fortress, so the number of connections is the number of related files (not the number of files inside)

time is the last modification timels--full view LS help document: Man Lsinfo ls Example 1: Suppose Test1, test2, test3 belong to testgroup this group, if there are two files below, please explain the owner of the two files and their related permissions?-rw-r--r--1 root root 238 June 17:22 Test.txt-rwxr-xr--1 test1 testgroup 5238 June, 10:25 Ping_tsai1. Belongs to root so everyone else is Others can only read2. test1 rwx all OKtest2/test3 Rxok can read can performother users (people not in the group that the file belongs to ) R read-only ( includes root) Example 2:If my directory is the bottom style, will testgroup members of this group and others (others) have access to this directory? drwxr-xr--1 test1 testgroup 5238 June, 10:25 groups/test1 rwx Oktestgroup Group of people that only [r-x] can enter this directory but cannot write to other users only R can read this directory What's there to do but not go in (x) cannot write (W)
    • Summary
    • For the catalog R---can see what's inside
    • W-----equivalent to file object can create files/delete inside
    • x------can go in.
    • Change file properties and Permissions of course to use the root user
that's all 3 commands:chgrp Change the grp file belongs to the groupchown Change own file ownerchmod changing Permissions

-R All files are changed at the bottom. Separateduser name. Group name modify two properties at a timeBut if you like to add a decimal point to your account, you'll have a system miscalculation. When you know how to change the group and owner of a file, when do you want to use Chown or chgrp? Maybe you'd be surprised, right? Yes, sometimes it is necessary to change the owner of the file, the most common example is to copy the file to other people outside of you, we use the simplest CP command to illustrate:
[[email protected] ~]# CP source file Destination file
Suppose you are going to copy the. bashrc file to the. bashrc_test filename and to the bin this person, you can do this:
[[email protected] ~]# CP. BASHRC. bashrc_test [[email protected] ~]# ls-al. bashrc*-rw-r--r--1 root root 395 Jul 4 11: bashrc-rw-r--r--1 root root 395 Jul 11:31. Bashrc_test <== The properties of the new file have not changed
Becausethe copy behavior (CP) replicates the properties and permissions of the performer, so! What to do? The . Bashrc_test is still owned by Root, so that even if you take the file to the bin user, he still can't modify it (see Properties/Permissions to know it), so you have to change the owner and group of the file! You know how to change it?

This third way for small changesA lot of people in the station are stuck in some permission settings, for example, they want to open the data for users to browse, lack ofonly open the permissions of R, which causes the Web server to not go to this directory to view, can only be viewed outside this document (R), The so-called far view and can not be obscene play.[R-x]But note that R-x's permissions are important to user, and W permissions cannot be given as an example: assuming an account name is Dmtsai, his home directory has [rwx] permissions to this directory/home/dmtsai/,dmtsai. If there is a file named The_root.data in this directory, the file has the following permissions:-rwx------1 root root 4365 Sep 23:20 the_root.dataWhat is the Dmtsai permissions on this file? Can I delete this file? A: Dmtsai to this file belongs to the others, the file is not readable non-change content is not executableSee if a file can be deleted, to observe whether the user has the upper level of the W permissions, here Dmtsai to dmtsai/directory has rwx permissions, that is, all the files in this directory can be deleted or added Look Back:Linux in each file, according to the rights are divided into users, groups and other people three identities; one of the most useful features of a group is when you develop resources in the team, andEach account can have multiple groups of support;If the file name is preceded by one more. ", then the file is" hidden files "; Change the file's group support available CHGRP, modify the file's owner available chown, modify the file's permissions can be chmodchmod modify the permissions of the method there are two ways, respectively, is the symbolic method and the digital method, the number method R,w,x score is 4, 2, 1; notation: ug=wx,o=r There is also a small way to make changes: A+w,u-r,o+x,g-w to the file, the effectiveness of the permissions are:
    • R: can read the actual content of this file, such as reading the text file content, etc.;
    • W: can edit, add, or modify the contents of the file (without deleting the file);
    • X: The file has permissions that can be executed by the system.
For a directory, the performance of the permission is:
    • R (Read contents in directory)
    • W (Modify contents of directory)
    • X (Access directory)
To opendirectory for anyone to browse, should at least give R and X permission, but W permission not to give;

Linux file permissions

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.