File Rights Management

Source: Internet
Author: User

I. Linux file Rights Management 1.st_mode
(1) St_mode record the permissions of the file, he is actually a 32-bit number, unsigned long type.
(2) St_mode is automatically written by the kernel when the System API stat function is called
2. Permissions List
(1) Altogether 9 bits, 3 groups. The first group represents the file's owner, user, and the readable, writable, and executable permissions for the file, and the second group is the permission of the group to which the master resides; The third group is the other others permissions on the file.
(2) who is the owner of the file that is usually created.
(3) You can change the permissions by chmod, Chown change the owner, chgrp the group in which the change is made.
3.access function Check Permissions
(1) The design of the software should be, before the operation of a file to determine whether there is currently permission to do this operation, if there is permission to continue to operate, otherwise provide error information to the user.
(2) The Access function can test whether the user who is executing the program has some kind of operation permission on the target file in the current environment.
(3) Access function prototype
#include <unistd.h>
int access (const char *pathname,int mode);
MODE:R_OK, W_OK, X_OK, F_OK f_ok test file exists
return 0 means: Yes,-1 means: No
4.chmode/fchmod and Permissions Modification
(1) chmod is a Linux command, only the root user has the right to perform modify permissions.
(2) The chmod command is implemented by invoking the function chmod function of the system API.
5.chown/fchown/lchown and Owner Modification

6.umask with file permission mask
(1) The file mask is a global setting maintained in the Linux system.
(2) Umask set the default permissions when the user creates the file.It is the opposite of chmod's effect, Umask sets the "complement" of the permission, and chmod sets the file permission code. You typically set the Umask value in/etc/profile, $ [Home]/.bash_profile, or $[home]/.profile.
(3) Usage of umask:
Linux command line: umask xxx (3 digits)
The file is generally created with no executable permission and the directory is allowed.
Umask is to remove a permission from the file.
For example: Umask 002 When creating a file, the permissions of the file is 664, when the directory is created, directory permissions are 775



From for notes (Wiz)

File Rights Management

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.