Calculate file permissions based on the Umask value

Source: Internet
Author: User

Old boy Linux OPS training

The core thoughts of the old boys ' education and teaching 6: Re-goal, re-thinking, method, practice, habit, re-summary

Life-long learning, the old boy education to achieve your starting point!

Believe that you believe in the old boy!!!

Copyright Notice:

This method follows Oldboy Derivation, must respect the author!!!

http://oldboy.blog.51cto.com/2561410/1060032

The writer is the old boy Linux OPS training student- Zhang Zhiqiang

all the contents of this article are from the old boys training Command Summary , without the training permission of the old boy and I, prohibit to be forwarded and use privately.

QQ: 1344683865

E-mail: [email protected]

Contact information:

Website operation and Maintenance Communication Group:




linux  qq 385168604

architect QQ Communication Group  390642196



Python QQ Communication Group 29215534

Big Data QQ Communication Group 421358633



===================================================================================




old boy Linux Training Contact Information




Consulting QQ

41117397 (Daniel)

70271111 (Crooked)



80042789 (Snow)

390320151 (light rain)



41117483 (Ice ice)



Phone:

158-1059-0206 (Daniel)

189-1171-8229 (Crooked)



135-5261-2571 (Snow)

186-0046-2391 (light rain)


website :

http://www.etiantian.org

Http://www.oldboyedu.com


Blog :

Http://oldboy.blog.51cto.com

Http://blog.oldboyedu.com






1th Chapteraccording toUmaskvalue, calculating file permissions1.1Numeric Method Calculation1.1.1for Files

use 666 to calculate

if umask any one of the values is an even digit, the direct minus umask value

666-002=664

[Email protected] tmp]$ umask002

[Email protected] tmp]$ touchf002

[Email protected] tmp]$ ls-l f002

-rw-rw-r--1 Xeon Xeon 0 APR 2 13:22 f002


if umask if the value of any bit has an odd number, it is reduced, and any bit odd digit is added 1 that's right.

666-123=543+101=644

[Email protected] tmp]$ umask123

[Email protected] tmp]$touch f123

[email protected] tmp]$ ls-l f123

-rw-r--r--1 root root 0 Apr 6 13:24 f123

1.1.2for Catalogs

in terms of catalogs, it is 777-umask it's over.

777-022=755

[Email protected] tmp]$umask 022

[Email protected] tmp]$ mkdird022

[Email protected] tmp]$ ls-ld d022

Drwxr-xr-x 2 Xeon Xeon 4096 Apr 2 13:43 d022

1.1.3Summary

Default Maximum Permissions

umask value

User-created permissions

Create a file ( umask all bits are even)

666

002

664

-rw-rw-rw-

--------W

-rw-rw-r--


(default maximum permissions) - ( umask permissions) = (user-created permissions)




Create a file ( umask some or all of the digits are even)

666

123

644

-rw-rw-rw-

---x-w--wx

-rw-r--r--


(default maximum permissions) - ( umask permissions) + ( umask odd number of arbitrary digits plus 1 ) = (user-created permissions)




Create a Directory

777

022

755

Drwxrwxrwx

D----w--w-

Drwxr-xr-x


(maximum default permissions) - ( umask permissions) = (user-created permissions)




1.2umask-scalculation Method1.2.1for Files

( umask value any bit with even)- (umask x on the value of any even digit )= (user-created permissions)

Owner - x , belong to group - x , other users - x

[Email protected] tmp]$ umask002

[Email protected] tmp]$ touchf002

[Email protected] tmp]$ umask-s

U=RWx, G=RWx, o=rx

[Email protected] tmp]$ls-l f002

-RW-rw-R- 1 Xeon Xeon 0 APR 2 13:22 f002

Genus Group - x

[Email protected] tmp]$ umask123

[Email protected] tmp]$ touchf123

[email protected] tmp]$ umask-s

U=rw,g=rx, O=r

[email protected] tmp]$ ls-l f123

-rw-r--r--1 root root 0 Apr 6 : f123

1.2.2for Catalogs

umask-s value is the user-created permission

[Email protected] tmp]$umask 022

[Email protected] tmp]$ mkdird022

[Email protected] tmp]$ umask-s

U=rwx,g=rx,o=rx

[Email protected] tmp]$ ls-ld d022

Drwxr-xr-x 2 Xeon Xeon 4096 Apr 2 13:43 d022

[Email protected] tmp]$ umask033

[Email protected] tmp]$ mkdird033

[Email protected] tmp]$ umask-s

U=rwx,g=r,o=r

[Email protected] tmp]$ ls-ld d033

drwxr--r--2 Xeon Xeon 4096 Apr 2 13:45 d033

1.2.3Summary

Default Maximum Permissions

umask value

user-created permissions are equal to umask-s

umask value

user-created permissions are equal to umask-s

Create a file ( umask can be odd and even)

666

002

664

123

644

-rw-rw-rw-

--------W

-rw-rw-r--

---x-w--wx

-rw-r--r--

( umask value any bit with even number) - ( umask value on any even digit. x ) = (user-created permissions)

Create a Directory

777

022

755

333

444

Drwxrwxrwx

D----w--w-

Drwxr-xr-x

D-wx-wx-wx

dr--r--r--

umask-s value is the user-created permission


This article is from the "Drifting Youth" blog, please be sure to keep this source http://pldqc.blog.51cto.com/4413174/1761128

Calculate file permissions based on the Umask value

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.