news 2026/4/23 19:23:53

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/23 13:30:51

Langchain-Chatchat向量数据库选型建议(Chroma/FAISS/Milvus)

Langchain-Chatchat向量数据库选型建议(Chroma/FAISS/Milvus) 在构建本地知识库问答系统时,一个常见的挑战是:如何让大语言模型(LLM)准确回答基于企业私有文档的问题?毕竟,通用模型并…

作者头像 李华
网站建设 2026/4/23 12:24:29

智能体之构建长短期记忆:深入解析 mem0 框架与实战

摘要:大模型(LLM)天生是无状态的,但在构建真正可用的 AI Agent(智能体)时,记忆能力是区分“玩具”与“产品”的关键分水岭。本文将深入探讨智能体长短期记忆的设计哲学,引入下一代记…

作者头像 李华
网站建设 2026/4/23 13:58:13

夸克网盘不限速的方法 - 破解高速下载

今天教大家一招能解决夸克网盘限制的在线工具。这个工具也是完全免费使用的。下面让大家看看我用这个工具的下载速度咋样。地址获取:放在这里了,可以直接获取 这个速度还是不错的把。对于平常不怎么下载的用户还是很友好的。下面开始今天的教学 输入我给…

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

阿里云基因测序数据分析平台有哪些成功案例?

阿里云基因测序数据分析平台在行业内拥有丰富的成功案例,已服务超过200家生物医药机构,涵盖基因测序、药物研发、临床数据分析等多个领域。头部基因测序企业合作案例华大基因是阿里云最重要的合作伙伴之一。通过阿里云基因分析平台,华大基因实…

作者头像 李华