umask (user file creation mask) controls the default permissions assigned to newly created files and directories in a Unix-like operating system. It determines which permission bits are turned off when a file or directory is created.
Default Permissions:
- For files, the default permissions are typically
666(read and write for owner, group, and others). - For directories, the default permissions are usually
777(read, write, and execute for owner, group, and others).
How umask Works:
The umask value is subtracted from the default permissions. For example:
- If your
umaskis set to022, the permissions for new files will be:- Files:
666 - 022 = 644(read and write for owner, read for group and others) - Directories:
777 - 022 = 755(read, write, and execute for owner, read and execute for group and others)
- Files:
Checking umask:
You can check the current umask value by running:
umask
Setting umask:
You can set a new umask value using:
umask 027
This would set the permissions for new files to 640 and directories to 750.
If you have more questions or need examples, feel free to ask!
