当前位置: 首页 > news >正文

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.

http://www.cnnetsun.cn/news/158509.html

相关文章:

  • 如何配置IPv6静态路由?解决企业网络难题
  • 【Linux网络基础】详解 TCP 面向连接 vs UDP 无连接
  • Langchain-Chatchat如何评估问答质量?指标体系构建
  • springboot在线教育系统(11528)
  • 测了多款AI自动生成PPT工具,真正能用的不到一半
  • springboot星之语明星周边产品销售网站的设计与实现(11529)
  • 毕设救星:Spring Boot + Neo4j 打造“医疗知识问答”——基于知识图谱的智能导诊平台
  • 华为网络设备基本配置命令
  • 志同道合交友网站毕业论文+PPT(附源代码+演示视频)
  • 【Java 25 LTS六大核心特性】
  • Langchain-Chatchat助力医疗文档智能检索与问答
  • Langchain-Chatchat如何实现文档相似度比对?查重与去重依据
  • java学习--String和StringBuffer互转
  • 如何用Langchain-Chatchat实现本地化AI智能问答?
  • Langchain-Chatchat如何处理多义词歧义?上下文感知消歧算法
  • Langchain-Chatchat如何实现文档访问统计?了解知识使用情况
  • Langchain-Chatchat与Argo CD持续交付集成:自动化部署流水线
  • Langchain-Chatchat与Consul服务发现集成:动态节点管理
  • Langchain-Chatchat与Airflow工作流集成:复杂ETL流程调度
  • 验证码实现
  • 2.1 CPU脚本性能优化简介
  • Langchain-Chatchat问答系统压测报告:万级QPS承载能力验证
  • Langchain-Chatchat支持自定义元数据字段:扩展文档属性信息
  • 双侧独立电驱动车辆转向控制:Matlab/Simulink建模之旅
  • 500kW三相光伏并网逆变器仿真模型探索
  • 基于Optislang的电机多目标优化:以电机气息磁通密度空间某一阶次为优化目标教程
  • 彼得林奇对公司自由现金流转换率的分析
  • 通达信止损价位
  • Langchain-Chatchat与Elasticsearch集成:增强全文检索能力
  • 历年中国海洋大学计算机考研复试上机真题