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/7 19:32:49

【完整源码+数据集+部署教程】危险场景检测系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]

一、背景意义 随着城市化进程的加快和工业化水平的提高,危险场景的发生频率逐渐上升,给人们的生命财产安全带来了严重威胁。传统的危险场景监测手段往往依赖于人工巡查和简单的监控设备,存在反应慢、覆盖面窄等缺陷,难以实现实时、…

作者头像 李华
网站建设 2026/6/4 16:25:20

考研加油上岸祝福弹窗程序

https://www.bilibili.com/video/BV1zdBFBbEvj/https://www.bilibili.com/video/BV1zdBFBbEvj/ GraduateAnchor - 考研祝福弹窗程序​ 项目简介 GraduateAnchor(考研上岸)是一个充满温暖与祝福的桌面应用程序,专为考研学子设计。程序运行后…

作者头像 李华
网站建设 2026/6/8 14:53:34

【开题答辩全过程】以 基于Java的打车拼车系统的设计与实现为例,包含答辩的问题和答案

个人简介一名14年经验的资深毕设内行人,语言擅长Java、php、微信小程序、Python、Golang、安卓Android等开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。感谢大家的…

作者头像 李华
网站建设 2026/6/4 16:25:17

算法杂谈:回溯路线

目录 前言 在动态规划中: 在bfs中: 前言 对于普通的路线问题,我们可以存储全局变量path存储路线过程中的,一个个“点”。由于这些点就是按照顺序存储的,路线就是可以直接得到的。 但是如果是动态规划,…

作者头像 李华
网站建设 2026/6/9 4:26:17

Langchain-Chatchat如何处理嵌套引用?复杂文档结构解析

Langchain-Chatchat如何处理嵌套引用?复杂文档结构解析 在企业知识库系统日益普及的今天,一个核心挑战浮出水面:如何让AI真正“读懂”那些充满脚注、交叉引用和层级结构的专业文档?比如一份科研报告中写着“详见[1]”,…

作者头像 李华
网站建设 2026/6/8 10:57:51

Langchain-Chatchat开源项目实战:构建企业级知识库问答系统

Langchain-Chatchat开源项目实战:构建企业级知识库问答系统 在企业数字化转型的浪潮中,一个现实而紧迫的问题日益凸显:海量文档沉睡在共享盘、邮箱和员工电脑里,真正需要时却“看得见、找不到、用不上”。新员工入职培训耗时数周&…

作者头像 李华