Learning from Linux for the elder brother Bird (5)--linux file permissions and directory settings

Source: Internet
Author: User
Tags readable

As mentioned earlier, one of the biggest features of Linux is that it allows multiple people to multitask, but what if a user can access another user's files, is there a security risk? In view of this, in order to allow each user to have a more confidential file data, Linux to the Rights management of the file processing, the identity of the file can be accessed into owner/group/others, and three kinds of identities have read/write/execute three kinds of permissions.

1. Owner is well understood, is the file owner. This file was created by you, and you are owner.

Group from the overall point of view, such as you are Class 3, so that the other three classes of students and you belong to the group of 3, they have a permission to your file.

Others, of course, is the access to your files from people outside Class 3. The following diagram is a good understanding:

As for the Tenjin, the so-called Root, which has the highest privileges, can access all files.

2. All the accounts on Linux are recorded in the/etc/passwd, and the user's login password is stored in the/etc/shadow, as for the group name is stored in/etc/group.

3. If we execute Ls-al (listing all the archive information) at the terminal, we can see similar information as follows:

The-rw-r--r--in front is the permission information. A total of 10, we take out the first position, while the latter 9 bits per 3 bits are taken out, respectively, recorded as 1.-,2.RW-,3.R--,4.R--。

1)-: File type, there are 3 common, where d indicates that the file is a directory,-indicates that the file is a file, l indicates that the file is a link, similar to a shortcut in Windows.

2) rw-: This is owner's permission, R is readable, W is writable, X is executable, and this third is-----Indicates that owner cannot execute the file, but can read and write operations.

3) R-:group permissions. The other members of this group can only read the file.

4) R--:others permission, other people can only be read.

So the above information means that the owner of the Install.log file is root, the group is also root,root can access the file, others can only read this file.

It is also important that if the identity does not have an X permission, then that identity cannot enter the directory!

4. Once you know the properties and permissions of the file, we'll talk about how to change these permissions, and here are three instructions: Chgrp,chown,chmod.

CHGRP: Change the group you belong to. For example, if you execute CHGRP users Install.log, the Install.log group will become users instead of the root mentioned above.

Chown: Change the file owner. Ibid., Chown users Install.log, the owner of the file becomes users. In addition we can change the group and owner at the same time, using Chown root:root Install.log will be Install.log group and owner of the same root

chmod: Change Permissions. In Linux, the r,w,x are given a value of 4,2,1, and each identity has its own three permission scores that need to be accumulated, such as the score for-RWXRWX---:

Owner--4+2+1=7

Group--4+2+1=7

Others--0+0+0=0

The number of permissions on the file becomes 770. Use chmod to change this permission value, such as executing chmod 777 1.log, which means to make 1.log permissions into-rwxrwxrwx, now understand.

5. There is also a way to change permissions, using U,g,o to represent the rights of the three identities, and a for all identities. Therefore, for example, the instruction chmod U=rwx,go=rx 1.txt means that the user can read and write the file, and the group and others can only be readable and executed. CHMD A+w 1.txt That is, everyone can write.

6. The ability of the next file in Windows to execute is determined by the extension, such as. Exe,.bat, and, in Linux, whether the file is executed to see if it has permission to X.

7. Su-user This instruction can be changed to user identity.

8. The following extensions are common under Linux:

. sh--script or batch file

. z,.tar,.tar.gz,.zip,.tgz--Packed Compressed files

. html,.php--Web Page Related documents

9. Finally, we will introduce several common Linux directories and contents:

/bin: The instructions that all users are able to manipulate are placed inside.

/dev: Any device or interface device is stored in this directory in the form of an archive.

/etc: The main configuration file of the system is placed in this directory, such as the user's account password file, various service opening files and so on.

/MNT: Mounted Additional device

/sbin: Only root can use the instructions inside.

/lost+found: The goal is to place some missing fragments in this directory when a file system error occurs.

There are absolute and relative paths in Linux, and absolute paths start with/start, that is, the root directory starts, and not the/start path is a relative path.

11: Indicates the current directory,.. Represents the previous directory.

Learning from Linux for the elder brother Bird (5)--linux file permissions and directory settings

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.