GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — linux-command/command/chattr.md at master · javamickey/linux-command

Expand file tree

/

chattr.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (39 loc) · 1.37 KB
/

chattr.md

Copy path

File metadata and controls

55 lines (39 loc) · 1.37 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

chattr

用来改变文件属性

补充说明

chattr命令 用来改变文件属性。这项指令可改变存放在ext2文件系统上的文件或目录属性,这些属性共有以下8种模式:

语法

chattr(选项)

选项

a:让文件或目录仅供附加用途;
b:不更新文件或目录的最后存取时间;
c:将文件或目录压缩后存放;
d:将文件或目录排除在倾倒操作之外;
i:不得任意更动文件或目录;
s:保密性删除文件或目录;
S:即时更新文件或目录;
u:预防意外删除。
-R:递归处理,将指令目录下的所有文件及子目录一并处理;
-v<版本编号>:设置文件或目录版本;
-V:显示指令执行过程;
+<属性>:开启文件或目录的该项属性;
-<属性>:关闭文件或目录的该项属性;
=<属性>:指定文件或目录的该项属性。

实例

用chattr命令防止系统中某个关键文件被修改:

chattr +i /etc/fstab

然后试一下rm、mv、rename等命令操作于该文件,都是得到Operation not permitted的结果。

让某个文件只能往里面追加内容,不能删除,一些日志文件适用于这种操作:

chattr +a /data1/user_act.log
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.