news 2026/6/9 16:05:56

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/8 14:11:19

Netty(20)如何实现基于Netty的WebSocket服务器?

要实现基于Netty的WebSocket服务器,您可以按照以下步骤进行操作,并结合代码示例进行详细解释: 创建服务器引导程序(ServerBootstrap): 首先,您需要创建一个ServerBootstrap实例,并配…

作者头像 李华
网站建设 2026/6/5 12:47:17

如何在ENSP中划分VLAN,解决网络拥堵问题?

最近,小王所在的公司遇到了一个棘手的问题:随着业务扩展,原有的网络架构已经无法满足日益增长的数据传输需求。特别是在高峰期,网络延迟和丢包现象频发,严重影响了员工的工作效率。于是,小王决定尝试通过划…

作者头像 李华
网站建设 2026/6/9 10:45:45

Langchain-Chatchat文档解析流程全解析:结构化你的非结构数据

Langchain-Chatchat文档解析流程全解析:结构化你的非结构数据 在企业知识管理的日常中,你是否遇到过这样的场景?一位新员工想了解公司差旅报销标准,翻遍了OA公告、制度手册和内部Wiki却找不到完整信息;或是法务同事需…

作者头像 李华
网站建设 2026/6/10 10:11:25

Langchain-Chatchat权限控制机制设计与实施

Langchain-Chatchat权限控制机制设计与实施 在企业逐步将大型语言模型(LLM)引入内部知识管理系统的今天,一个看似简单的问题却成了落地的“拦路虎”:如何让AI既聪明又守规矩? 设想这样一个场景:某集团财务部…

作者头像 李华
网站建设 2026/6/10 10:12:03

基于YOLOv8/YOLOv10/YOLOv11/YOLOv12与SpringBoot的前后端分离花生种子霉变识别检测系统(DeepSeek智能分析+web交互界面)

项目摘要 本项目旨在开发一个基于深度学习与Web技术的前后端分离式花生种子霉变智能识别与检测系统。系统核心采用先进的YOLOv8/v10/v11/v12系列目标检测模型,对花生种子图像进行高效、精准的二分分类(‘with mold’ 霉变 / ‘without mold’ 正常&…

作者头像 李华