umask - macOS
Overview
umask is a macOS command used to set or display the file mode creation mask. It allows you to specify the default permissions for newly created files and directories.
Syntax
umask [-S] [-s] [-u] [mask]
Options/Flags
- -S, –symbolic: Symbolically display the file mode creation mask.
- -s, –status: Display the current file mode creation mask.
- -u, –unset: Revoke file mode creation mask permissions.
- mask: An octal number representing the file mode creation mask.
Examples
Display Current Mask
umask -s
Set Mask Symbolically
umask -S u+w,go-wx
Set Mask Octal
umask 0046 # Set user read and write, group and other read
Common Issues
- Incorrect mask format: The mask argument must be a valid octal number (0-7).
- Invalid permissions: Ensure that the permissions specified in the mask are valid (e.g., user write permission cannot be revoked for user-owned files).
Integration
umask can be used in conjunction with other commands to control file permissions. For example:
touch file
umask 022
chmod -R g+w file
This command creates a file with default permissions, then changes the mask to restrict group write permissions, and finally grants group write permissions recursively to the file.
Related Commands
- chmod: Change file permissions.
- chown: Change file ownership and group.
- stat: Display file attributes, including permissions.