news 2026/7/3 18:06:41

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/6/28 20:53:57

如何配置IPv6静态路由?解决企业网络难题

说到网络配置,尤其是涉及到IPv6的时候,很多人可能会感到头疼。毕竟,这不仅仅是技术问题,更是关乎到整个企业的数据传输效率和安全性。在这样的背景下,如何正确地配置IPv6静态路由成为了一个值得探讨的话题。先来聊聊为…

作者头像 李华
网站建设 2026/7/3 9:45:23

【Linux网络基础】详解 TCP 面向连接 vs UDP 无连接

详解 TCP 面向连接 vs UDP 无连接 本文详细解析计算机网络传输层两个最重要的协议:TCP (Transmission Control Protocol) 和 UDP (User Datagram Protocol),重点阐述“面向连接”与“无连接”的核心区别、工作原理及应用场景。1. 核心概念:什…

作者头像 李华
网站建设 2026/6/28 23:06:10

Langchain-Chatchat如何评估问答质量?指标体系构建

Langchain-Chatchat如何评估问答质量?指标体系构建 在企业知识管理日益智能化的今天,一个常见的困境是:员工每天要花数小时查找文档、邮件或内部系统中的信息,而客服面对客户提问时却常常无法快速调取准确答案。尽管大语言模型&am…

作者头像 李华
网站建设 2026/7/2 9:08:33

springboot在线教育系统(11528)

有需要的同学,源代码和配套文档领取,加文章最下方的名片哦 一、项目演示 项目演示视频 二、资料介绍 完整源代码(前后端源代码SQL脚本)配套文档(LWPPT开题报告)远程调试控屏包运行 三、技术介绍 Java…

作者头像 李华
网站建设 2026/7/1 9:29:59

测了多款AI自动生成PPT工具,真正能用的不到一半

告别PPT制作难题!轻竹办公让汇报高效出彩在职场中,年终总结、项目汇报等工作如同一座座大山,压得职场人喘不过气来。为了一份完美的报告,我们常常熬夜修改,好不容易搭建好框架,内容却缺乏亮点;精…

作者头像 李华
网站建设 2026/7/1 15:46:10

springboot星之语明星周边产品销售网站的设计与实现(11529)

有需要的同学,源代码和配套文档领取,加文章最下方的名片哦 一、项目演示 项目演示视频 二、资料介绍 完整源代码(前后端源代码SQL脚本)配套文档(LWPPT开题报告)远程调试控屏包运行 三、技术介绍 Java…

作者头像 李华