Novice Tutorials for file permissions (umask, chmod, read, write, execute)

Source: Internet
Author: User
Tags chmod numeric file permissions

UNIX file and directory Access can be viewed as a form of a 3*3 matrix.

That is, three Access objects (owner,groups,others, user groups, others), each with three access rights (Read,write,execute read, write, execute).

111 binary means 7,100 is 4 if you make it readable, it's 110 (6) You can view the permissions settings for a file or directory by using the Ls-l command. The second character in the output to the tenth character, which represents three access rights for each of the three user types.

-rw-r--r--1 Sathiya Sathiya 272 The example above: * The user is the owner (08:22) has read and Write permission (R on behalf of Test.txt representative Sathiya representative of Execute [translator])

* Other users in the user group have read (reads) permission * Other users have read (reading) permission three file access rights:

* READ: Permission to read the contents of the file * Write (Write): Permission to write File * Execute: Has permission to execute a file as a program or script three directory access: * Read (Read): Permission to read the contents of the directory (displays the files and children in this directory) directory).

* Written (write): have permission to write to the directory (create files and subdirectories in this directory) * Execute: Numeric values for read (read), write (write), and execute (EXECUTE) permissions for opening this directory: * Read (Read) 4 * Write (WR ITE) 2 * Execute (EXECUTE) 1 if you want a combination of multiple permissions, just add the corresponding values.

For example: Require Read and Write permission (read,write), then is 4+2 = 6. Use Chmod to change permissions on a file or directory you can change the permissions of a file or directory by using octal numeric representations or character representations. Octal representation of permissions (in order from left to right): * First digit for owner (owner) * Second digit for user group * Third digit for other users if you want to give the owner (owner) read-write (read 4, write 2, 4+2=6) permission, and give the user group (Grou p) and other users (others) read (read 2) Permission: $ chmod 644 file name if you want to give the owner (owner) Read and execute (read 4, execute 1,4+1=5) permission, and give the user group (read 4) permission, and give other users 0 permissions (0): $ chmod 540 filename If you want to give the owner read-write (read 4, write 2, 4 + 2 = 6) permission, and give the user group 0 permission (0) and give the other user read (read 4) Permission: $ chmod 604 FileName Umask 022 represents the default permissions for a file the default Umask value is 0022, which represents the default permissions for a new file or directory.

The default permission for the directory is 0777, and the default permission for the file is 0666, and the new file or directory permissions are the default permissions minus the Umask value of 0022.

The default permissions for final files are calculated as follows: * Default file permissions: 666 * Default Umask value: 022 * Final file default permissions: 644 The default permissions for the final directory are calculated as follows: * Default directory Permissions: 777 * Default UMASK:022 * Final default directory permissions: 755 you can Based on the above calculation method, change the umask to the desired value. For example, if you want to have 0 (0) permissions on a file or directory for anyone other than the owner (owner), you can set the Umask value to 0077.

$ umask 0077 Then, if you create a new file or directory, the user will have the following permissions: $ > testfile$ ls-l testfile-rw-------1 sathiya sathiya 0 Mar 08:23 Test File

Original address: http://bbs.weiphone.com/read-htm-tid-1311002.html

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.