news 2026/5/1 6:57: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/5/1 6:57:30

Langchain-Chatchat与企业微信/钉钉集成方案

Langchain-Chatchat 与企业微信/钉钉集成:打造安全高效的本地化智能助手 在现代企业中,员工每天都要面对海量的制度文件、产品手册和流程规范。但真正需要时,却常常“文档找不到、政策记不清、问题反复问”。HR一遍遍解释年假规则&#xff0c…

作者头像 李华
网站建设 2026/4/29 2:17:46

Langchain-Chatchat在ERP系统中的智能辅助应用

Langchain-Chatchat在ERP系统中的智能辅助应用 在企业数字化转型的浪潮中,ERP系统早已不再是简单的流程管理工具,而是承载着财务、人力、供应链等核心业务逻辑的中枢平台。然而,一个长期被忽视的问题是:员工每天花多少时间在“找信…

作者头像 李华
网站建设 2026/4/28 10:38:50

GEO数据安全与合规:企业如何合法收集与使用用户位置信息

一、位置数据背后的法律红线在数字化转型浪潮中,用户位置信息已成为企业的宝贵资产,从精准营销到智能服务,应用场景日益广泛。然而,随着《个人信息保护法》《数据安全法》等法规的实施,位置数据的收集与使用已不再是技…

作者头像 李华
网站建设 2026/4/17 18:58:20

LOGO设计的底层逻辑:如何让品牌符号一眼难忘?

LOGO作为品牌视觉识别系统的核心载体,是用户对品牌形成第一认知的关键触点。一个成功的LOGO不仅能快速传递品牌信息,更能在用户心智中留下持久印象,成为区分同类品牌的独特符号。然而,很多设计实践中常陷入“美观优先”或“盲目跟…

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

基于C语言的学习---if语句

一、if语句的执行逻辑如果括号里面条件成立,那么就执行这个程序;不成立,就不做,跳过;if语句后面可有大括号也可以没有;二、判断的条件1、运算符条件2、关系运算的结果成立输出1;不成立输出0&…

作者头像 李华