Linux File Permission chmod chown

Source: Internet
Author: User

Linux File Permission chmod chown

1. Linux File Access Permissions

Chmod is short for change mode. Similarly, chown is the abbreviation of change owner. One is to change the access permission of the file, and the other is to change the owner of the file.

2. Change the file access permission chmod

For Linux Files, access permissions and file owner are two important attributes. The file access permission is probably like this. For example, in file access permission 3, one is read, and the other is read. The flag is 4, the other is write, and the other is x, the flag is 1, indicating the executable meaning (for a file, x indicates that the file can be executed, for a directory, x indicates that the directory can be accessed, that is, cd can be included ). For a specified user, if the mode value for a file is 7, the user has the permission for this file and rwx. This is a bit operation. I hope you can understand it carefully. 755 indicates that the owner has the rwx (read/write execution or access) permission on the file, and group_user has the rx permission on the file, others has the permission to read and write this file (rx ).

Chmod-R 755 *

We usually use the ll command or ls-al to list three digits. How can this problem be solved. Originally, this three-digit number represents the permissions of owner group_user others on this file, indicating that Linux is a multi-user operating system, A file can be viewed by different users. It is also necessary to explain the concept of group_user. in Linux, users can be grouped and multiple users in a group, therefore, a file must indicate that these three types of users have complete access permissions to the file. Otherwise, when a file is exposed to different types of users, how can the operating system handle this case? The above is basically a problem with file permissions. With this knowledge, you can set appropriate permissions for a file. If it is a directory, if you want to recursively Set permissions for each file in the directory, you can use the-R parameter.

3. Changed the attributes of the file user group chown.

The following is the content related to chown.

Each file has an owner, which is jointly determined by a group and a user. If you do not know your identity, you can use whoami to view it. If you do not know your current group, you can use groups to view all groups.

The common application scenarios of these two tools are as follows. You do not want to use sudo when editing a file. This file does not need to be protected, one way is to set the access permission of this file to 777, so that everyone can modify it without any protection. However, the other method is to set the owner of the file to your current user, or to allow him to edit the file without any restrictions. For example

Chown-R work: work .*

In this way, all files in the current directory can be set to work, the first work is the user name, and the second is the user group. It is usually the same. If you do not know, you can touch a file and then ls-al. In this case, check that the user and group of the new files listed are set to the same, you can cancel the trouble of losing the password.

Linux permission supplement: rwt rwT rws rwS special permissions

Linux User and User Group Permissions

Three special Linux permissions: setuid setgid stick bit

Getting started with Linux: A Brief Description of Linux File Permissions

Detailed description of user group and file permissions in Linux

This article permanently updates the link address:

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.