Protect your files. modify the Umask value in Linux.

Source: Internet
Author: User
This tutorial teaches Linux users how to change the Umask value of their systems permanently. We recommend that you learn from the newly installed users (if you want to know why, follow these steps ). What is Umask? UMASK stands for the user mask or the user file creation mask, which is used

 

This tutorial teaches Linux users how to change the Umask value of their systems permanently. We recommend that you learn from the newly installed users (if you want to know why, follow these steps ).

What is Umask? UMASK stands for the user mask or the user file creation mask. it is used for newly created files and folders and is the basis of its default permissions.

The above description can be interpreted as any Linux-based operating system that adds default permissions to new files (including folders. For educational purposes, the following lists some octal value masks that can be used to set file permissions:

 
  1. 0-read, write, executable (rwx)
  2. 1-read and write (rw -)
  3. 2-read and executable (r-x)
  4. 3-read-only (r --)
  5. 4-write and executable (-wx)
  6. 5-write only (-w -)
  7. 6-only executable (-- x)
  8. 7-no permission (---)

In almost all Linux releases, the default Umask value is 0022 (or 022). you can enter the umask command in the terminal simulation program to view it. You can also run the "umask octal mask" command (for example, umask 027) to temporarily change this value.

You may know that the default permission setting for the newly created file should be 0666, and the folder is 0777. Apply the umask value mentioned above and get the 644 and 755 permissions.

Many people think that the 022 mask will bring about privacy issues. that is to say, the files you create can be viewed by other users at will. it is not very nice to think of this!

To put it bluntly, you can modify the default Umask value as they wish. of course, you must first ensure that the modified value is valid. To modify the default value, write a new Umask value in your shell configuration file or/etc/profile file.

Okay, that's all! From now on, all newly created files or folders on your Linux system will have the correct settings. However, note that the permissions of existing files or folders will not be changed because of the above operations.

If you are using a command line, you can run the ls-lah command in any directory to view the current file permission. In addition, new users can easily view the file permissions. in the GNOME-based desktop environment, right-click the File and choose Properties> Permissions tab.

If you have any questions while reading this tutorial, do not hesitate to leave your comments.

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.