news 2026/4/16 14:39:59

umask Cheat Sheet - umask Command Line Guide

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
umask Cheat Sheet - umask Command Line Guide

Theumaskcommand in Linux is used to set or display the default file creation permissions (called the “user file-creation mask”) for new files and directories. When a new file or directory is created, the umask value is subtracted from the system’s default permission settings to determine the final permissions assigned to the file or directory.

By default, files are typically created with666permissions (read and write for everyone), and directories are created with777permissions (read, write, and execute for everyone). Theumaskcommand sets a mask that restricts these default permissions.

Basic Syntax:umask [MASK]

[MASK]: The permission mask to apply (as an octal value).

Without any arguments,umaskdisplays the current mask.

HowumaskWorks

  • Permissions for files: Files cannot have execute permissions by default. The default permission for files is666(read and write for all).
  • Permissions for directories: Directories can have execute permissions. The default permission for directories is777(read, write, and execute for all).

The umask value is subtracted from these defaults to calculate the actual permissions of the new file or directory.


Commonly Used Values

  • 002: Allows read and write for the owner and group, and read for others (775for directories,664for files).
  • 022: Allows read and write for the owner, read for the group and others (755for directories,644for files).
  • 077: Allows full permissions for the owner, no permissions for the group and others (700for directories,600for files).

umaskCommand Cheat Sheet

OptionDescriptionExample
umaskDisplays the currentumaskvalue in octal notationumask
umask -SDisplays the currentumaskvalue in symbolic (human-readable) notationumask -S
umask [MASK]Sets theumaskvalue to the specified maskumask 022
umask 077Restricts permissions to only the owner (no access for group and others)umask 077

Examples of Default File and Directory Permissions withumask

umaskValueFile PermissionDirectory PermissionDescription
022-rw-r--r--(644)drwxr-xr-x(755)Owner can read/write, group and others read only
002-rw-rw-r--(664)drwxrwxr-x(775)Owner and group can read/write, others read only
077-rw-------(600)drwx------(700)Only the owner has full permissions

Conclusion

Theumaskcommand is an essential tool for managing default file and directory permissions in Linux. By controlling theumask, you ensure that newly created files and directories have the appropriate permissions for your security and access control requirements. Understanding how to set and checkumaskvalues helps system administrators maintain security while facilitating user and group collaboration.

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/15 15:31:24

多模态大模型引领:计算机视觉的下一个爆发点

计算机视觉与模式识别正迎来 “多模态融合高效落地” 的双重爆发!如今的研究早已跳出单一视觉任务框架,核心突破集中在三大方向。多模态 LLM 成为绝对热点,视觉编码器与大语言模型深度整合,实现图像理解、跨模态检索与逻辑推理的无…

作者头像 李华
网站建设 2026/4/16 10:57:23

测试深度思考:从执行者到战略家的思维跃迁

在软件测试领域,我们常陷于日常的用例执行、缺陷跟踪和报告编写中,仿佛测试就是一场“找茬游戏”。然而,随着敏捷开发、DevOps和AI技术的普及,测试角色正从被动的质量检验者向主动的质量赋能者演变。深度思考,正是这一…

作者头像 李华
网站建设 2026/4/16 12:52:10

10 个AI论文工具,MBA学生高效写作必备!

10 个AI论文工具,MBA学生高效写作必备! AI 工具助力论文写作,MBA 学生的高效之选 在当今快节奏的 MBA 学习中,论文写作已成为一项重要任务。无论是案例分析、商业计划书还是研究论文,都需要学生具备高效的写作能力与…

作者头像 李华