Linux umask and chmod

Source: Internet
Author: User

Function Description: Specifies the default permission mask when creating a file.

Syntax:Umask[-S] [permission mask]

Note:UmaskYou can set the [permission mask]. The [permission mask] is composed of three Octal numbers. After the existing access permissions are removed from the permission mask, the preset permissions for file creation can be generated.

Parameters:
-S indicates the permission mask in text format.

When you first log on to the system, the u m a s k Command determines the default mode of file creation. This command actually corresponds
The C h m o d command is the opposite. Your system administrator must set a reasonable u m a s k value for you to ensure that
Files have the desired default permissions to prevent other users from having the write permission on your files.
Example:

  $ umask u=rwx,g=rwx,o=  $ umask   0007  $ mkdir fu  $ touch bar  $ ls -l  drwxrwx--- 2 dave dave 512 Sep  1 20:59 fu  -rw-rw---- 1 dave dave   0 Sep  1 20:59 bar
 
$ umask 0022  $ mkdir xdir  $ touch xfile  $ ls -l  drwxr-xr-x 2 dave dave 512 Aug 18 20:59 xdir  -rw-r--r-- 1 dave dave   0 Aug 18 20:59 xfile
 

Enter at the terminal:
Ls-l File Viewing permission
These are the main reasons:
-RW-r --
A total of 10 digits
The first one represents the type (Directory D or file -)
The three RW in the middle indicates that the owner (User) has the Read and Write rights.
Then the three RW-indicate that the group has the Read and Write rights.
The last three R groups indicate that others (other) only have read permission.
Meaning of each character:
R indicates that the file can be read)
W indicates that the file can be written)
X indicates that the file can be executed (if it is a program)
-The permission has not been granted.
Chmod o + w xxx. XXX
Grant other users the permission to write the file XXX. XXX.
Chmod go-rw xxx. XXX
Deletes the read and write permissions of group groups and other persons in XXX. XXX.
Where:
U stands for the owner (User)
G indicates the group in which the owner is located)
O stands for others, but not u and g (other)
A Represents all people, including U, G, and O
Action:

+ Indicates adding permissions.

-Indicates the permission to be deleted.

= Indicates that it is the only permission

Numeric representation:

Chmod 755 File

File Usage: The owner has the read and write permissions. users in the same group and other users only have the read and execution permissions.

 

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.