Sixth chapter Linux file permissions and directory configuration

Source: Internet
Author: User
Tags comparison table readable

One of the best places in Linux is his multi-tasking environment. In order for each user to have more confidential file data, the rights management of the file becomes very important. Linux generally divides the identity of the file into three categories, namely, owner/group/others, and three kinds of identities have read/write/execute and other rights. If management is improper, management will be very messy.  1 Users and Groups 2 Linux file permissions concepts      2.1 Linux files properties      2.2 How to change file properties and permissions: Chgrp,chown,chmod      2.3 directory and file permissions      2.4 Linux file types and Extensions 3 Linux directory configuration      3.1 Linux directory configuration by--f hs:/,/usr,/var     3.2 directory tree (dorectory tree)      3.3 absolute path vs. relative path      3.4 CentOS Observation: Lsb_release4 Focus Review 5 exercises  1 users and Groups       (1) file owners   Because Linux is a multi-tasking system, As a result, there may be a lot of people who use this host to work at the same time, so the role of the "file owner" is very important in order to consider everyone's privacy and the work environment that everyone likes.       (2) Group concept     Group One of the most useful features is when you develop resources in the team. Suppose there are two groups of subjects in my host, the first thematic group is PROJECTA, there are three members CLASS1,CLASS2,CLASS3, the second is PROOJECTB, and the members have CLASS4,CLASS5,CLASS6. There was a competitive nature between the topics, but the same report was to be submitted. Each group of members must be able to modify each other's data, but other group members can not see the group's own file content.    How is it implemented? We can restrict other people who are not on their own team from reading the content by having easy file access settings. Plus, if teacher this account is progecta,With PROGECTB the two topics of the teacher, he wants to observe the progress of both, so need to be able to access the two groups of permissions, you can set teacher this account "simultaneously support PROGECTA and PROGECTB these two groups"  2 Linux file Permissions concept   A general understanding of Linux users and groups, we want to learn how the permissions of this file to the so-called "user" and "group" to set.   2.1 Linux file properties       Since you want to understand the file attributes of Linux, then there is an important and commonly used instruction that must be learned, that is, "LS" is a view of the file instructions, after you log in as Root Linux, Release "Ls-al" to see   read the-rwxrwx--- * the first character means that the file is "directory, file or link files, etc.":  -when "D" is the directory-if "-" is the file-if "l" is the Link party (link File)-if "B" is indicated as a storage interface device (a random access device) inside the appliance file-if "C" means a serial port device inside the device file, such as a keyboard, mouse (one-time reading device)  * the next character, a group of three, and all "rwx" A combination of three parameters. where "R" stands for readable (read), "W" for Writable (write), "X" for executable (execute). Note that the location of the three permissions will not change, if there is no permission to drink a minus sign "-".  -The first group is "permissions for the file owner"-The second group is "permissions for the same group"-the third group is "permissions for other non-groups"   Example: if there is a file type and the permission data is "-rwxr-xr--" A: The entire type and permission data is first separately consulted, And will be a character collation is called as follows: [-][rwx][r-x][r--]1  234  567 890 1: Represents the file name as a directory or file, in this case the archive (-); 234: The owner's permission, in this case, is readable, writable, Executable (RWX); 567: Same group User rights, this example is readable executable (RX), 890 is: Other user rights, in this case is readable (r);   * the second column indicates how many file names are connected to this node (i-node):      Each file will have his permissions and attributes recorded in the file system's I-node, but the directory tree we use is written using the file nameRecord, so each file name is connected to a i-node, and this property records how many different file names are linked to the same i-node number.  * The third column indicates that the "owner account" of this file  * the fourth column indicates the group of this file * The size of the file, the default unit is bytes * Sixth column for the file's file date or the last modified date       If you want to display the full time format, you can take advantage of the LS option, which is: "Ls-l--full-time" will be able to display the full time format. If you originally installed your Linux system in Simplified Chinese, then the date will be displayed in Chinese, but Chinese is not able to display in plain text terminal mode correctly, then you have to use "LANG = en_US" To modify the language!       If you want to make the system default language into English, then you can modify the system configuration file "etc/sysconfig/i18n", using Nano to modify the contents of the file, so that lang this variable becomes the above content.  * The Seventh column is the file name for this file       This field is the file name. The special is: if the file name is more than one ".", then the file is "hidden file", you can use "ls" and "ls-a" two instructions to feel what is hidden files.      tips: For more detailed LS usage, do you still remember how to query? Yes, use the man ls or info ls to see his basic usage.   Example:  A: (1) The owner of the file Test.txt is root, the group belongs to root. As for the authority, only the root account can access this file, others can only read this file; (2) The owner of another file Ping_tsai is test1, and the owning group is Testgroup, where test1 can have a readable writable executable right for the side file , while the same group of Test2,test3 two people and Test1 are also testgroup group accounts, can only be read executable but not write (that is, modify); (3) As for non-testgroup This group of people can only read, cannot write or execute!   For example my directory for the following style, ask Testgroup this group members and others (others) can enter this directory?     drwxr-xr-- 1  test1 &nbspTestgroup  5238  jun  19 10:25 groups/A: The file owner is test1[rwx] can do any work in this directory, and testgroup this group [r-x] account, For example, TEST2,TEST3 can also enter this directory to work, but do not write in this directory to do the hands-on, as for the permissions of other "r--" although there is r, but because there is no permission to X, so others users, and therefore cannot enter this directory.  2.2 How to change file properties and Permissions:chgrp,chown,chmod     *CHGRP: Change the profile group      *chown: Change the profile owner   & nbsp  *chmod: Change file permissions, Suid,sgid,sbit and so on features   change a group of files directly to Chgrp to change. CHGRP is the abbreviation for Change group. Remember, however, that the group name to be changed must exist within the/etc/group file, or it will show an error!   Change the owner of a file? Very simple, chown, is the abbreviation for change owner, see example  

So when do you use Chown or chgrp? The most common example is to copy files to other people outside of you, we use the simplest CP command to illustrate: CP Source files target file * Change permissions, chmod file permissions to change the use of chmod this command, but, the permissions of the set method has two, respectively, can use the number     Words or symbols to make permission changes. The number type changes the file permissions The basic permissions of the Linux file are nine, respectively owner/group/others three kinds of identities have their own Read/write/execute permissions, the file's permission character is "-rwxrwxrwx", These nine permissions are three three groups! Among them, we can use the number to represent each permission, each permission score comparison table is as follows: R:4 w:2 x:1 each identity (owner/group/others) Each of the three permissions (r/w/x) score is required to accumulate, for example, when the permission is "-rwxrwx---" score is: O Wner = rwx = 4+2+1 = 7 Group = rwx = 4+2+1 = 7 others = 0+0+0 = 0 so wait a minute. When we set the change of the permission, the permission number of the file is 770, the instruction of Change permission chmod syntax is CH MoD [-r] XYZ file or directory

What if you want to turn permissions into "-rwxr-xr--"? Then the score of the permission becomes "4+2+1" "4+0+1" "4+0+0" = 754 so you need to release "chmod 754 filename", one case: after we use vim to edit a shell batch file, his permissions are usually-rw-rw-r-- That is, 664, if you want to turn the file into an executable file, and do not let others modify this file, then you need to-rwxr-xr-x such permission at this time to release chmod 755 test.sh In addition, if some files you do not want to be seen by other people, Then the permissions for the file should be set to such as "-rwxr-----" then release chmod 740 filename

Sixth chapter Linux file permissions and directory configuration

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.