news 2026/9/25 1:09:01

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/9/25 22:00:36

Langchain-Chatchat在金融行业知识库中的应用案例分享

Langchain-Chatchat在金融行业知识库中的应用案例分享 在金融机构的日常运营中,一个常见的挑战是:合规部门需要快速查找某项监管政策的具体条款,研究员要从上百份年报中提取关键财务数据,而客服人员则反复回答“产品A和产品B的区别…

作者头像 李华
网站建设 2026/9/25 6:59:23

跨境电商速卖通(AliExpress)数据采集与 API 接口接入全方案

速卖通作为全球主流跨境电商平台,其开放平台 API 是合规采集商品价格、库存、促销等核心数据的首选方式;针对无接口权限场景,也可通过合规爬虫补充采集。以下从API 接口接入(核心)、爬虫采集(补充&#xff…

作者头像 李华
网站建设 2026/9/25 7:01:09

直播抠图技术100谈之16----绿幕抠图中如何选择背景绿布

不废话 下面是一个饱和度是100%的色相图,从0–360度全覆盖, 要选择画红色框的那些绿布的颜色,不要选择红色框偏左边, 或偏右边的颜色; - 解释 1. 为什么不选红色框左边的颜色, 因为左边的是草黄绿 什么是草黄绿? 这是一种偏向黄色的浅绿,类似于新鲜草坪的…

作者头像 李华
网站建设 2026/9/25 14:04:09

Langchain-Chatchat与主流大模型集成的最佳实践

Langchain-Chatchat与主流大模型集成的最佳实践 在企业智能化转型的浪潮中,一个日益突出的问题浮出水面:通用大语言模型虽然“博学”,却对企业内部制度、项目文档、合规流程等私有知识一无所知。更令人担忧的是,将敏感文件上传至云…

作者头像 李华
网站建设 2026/9/25 18:26:02

基于YOLOv8/YOLOv10/YOLOv11/YOLOv12与SpringBoot的前后端分离疲劳驾驶识别检测系统(DeepSeek智能分析+web交互界面)

一、 系统引言 随着社会经济的快速发展,汽车已成为不可或缺的交通工具,但随之而来的道路交通安全问题也日益严峻。其中,疲劳驾驶是导致重大交通事故的主要因素之一,对驾驶员和公众的生命财产安全构成了严重威胁。统计表明&#x…

作者头像 李华
网站建设 2026/9/25 22:49:11

Langchain-Chatchat在政务知识库建设中的应用前景

Langchain-Chatchat在政务知识库建设中的应用前景 在政务服务日益智能化的今天,公众对政策咨询的期待早已超越了“能查到”,而是要求“秒懂、精准、可信赖”。然而现实是,大量群众面对冗长的法规条文和复杂的办事指南时仍感到无从下手。某市医…

作者头像 李华