Linux umask Default Rights Assignment command

Source: Internet
Author: User

Command for default permission assignment umask

[Email protected] test]# mkdir newdir

[email protected] test]# Touch NewFile

[Email protected] test]# LS-LRT

Total 4

Drwxr-xr-x. 2 root root 4096 Apr 17:07 newdir

-rw-r--r--. 1 root root 0 Apr 17:08 newfile

Create a directory with default permissions of 755

Create file, default permission is 644


Why is the default permission 755,644 instead of the other value?

Site Directory security permissions: Directory 755, File 644 is a relatively secure permission (user root and user group root)

Linux system default Permissions policy: Allow browsing, viewing, but prohibit creation and modification, add files and content.


Common users create files and directories

Table of Contents 775, File 664

[email protected] ~]$ Touch NewFile

[Email protected] ~]$ mkdir newdir

[Email protected] ~]$ LS-LRT

Total 8

-rw-r--r--. 1 ZJJ zjj 6 APR 11:22 hi.txt

-rw-rw-r--. 1 zjj zjj 0 Apr 17:23 newfile

Drwxrwxr-x. 2 zjj zjj 4096 APR 17:23 newdir

[Email protected] ~]$ umask

0002


Control the Umask place in/etc/profile

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/A8/wKiom1coEH2Qh_xvAALNboA-bZE671.jpg "title=" Prpfile.jpg "alt=" Wkiom1coeh2qh_xvaalnboa-bze671.jpg "/>

Such as:

[[email protected] ~]$ id-gnzdw[[email protected] ~]$ id-unzdw[[email protected] ~]$ umask0002

Note: The average user's umask may not be 002


FILE-only general calculation method:

Default file permissions calculation method under root

1. Assume that the Umask value is: 022 (all bits are even)

666 the start permission value of the ==> file

022-Value of ==>umask

------

644

2. Assume that the Umask value is: 045 (other user group bits are odd)

666 the start permission value of the ==> file

045-Value of ==>umask

------

621 ==> the computed permissions. Since the last digit of umask is 5, in the user group the odd digit plus 1

001+

------

622 ==> Real files are limited to


command example:

1.umask default 022 when creating directories and files

[[email protected] ~]# umask                                           #默认为0220022 [roo[email protected] ~ ]# cd /home/zdw/[[email protected] zdw]# mkdir 022dir                                  #创建文件夹 [[email protected] zdw]# ls - ld 022dir/                               #777-022 permission is 755drwxr-xr-x.  2 root root 4096 may  3 10:25 022dir/[[email protected]  zdw]# touch 022file                                #创建文件 [[email protected]  zdw]# ls -l 022file                                 #666-022 permissions for 644-rw-r--r--.  1 root root 0 May  3 10:26  022file

Note: The permissions of the folder maximum is 777, with 777-022, the permissions of the folder, the maximum file permissions of 666, with 666-022, the permissions of the file

2.umask set to 333

[[email protected] zdw]# umask 333                                     #更改umask为333 [[Email protected] zdw]# umask0333[[email  protected] zdw]# mkdir 333dir                                  #创建文件夹 [[email protected] zdw]# ls -ld 333dir/                                #777-333 permissions for 444dr--r--r--.  2 root root 4096  May  3 10:31 333dir/        [[email  Protected] zdw]# touch 333file                                #创建文件 [[email  protected] zdw]# ls -l 333file                                 #666-333 in odd digits plus 1 permissions for 444-r--r--r--.  1 root root 0 may  3 10:32  333file

Note: The odd permission bit does not affect the directory, the file bit is odd, plus 1 can


Learn from: Old boy

This article is from the blog "Write to Yourself", so be sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1769604

Linux umask Default Rights Assignment command

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.