leonheart 发表于 2018-5-22 09:27:36

linux之chattr命令

  

  chattr命令
  

  说明:改变文件的属性
  

  chattr [ -RVf ] [ -v version ] [ mode ] files...
  

  语  法:chattr [-RV][-v<版本编号>][+/-/=<属性>][文件或目录...]
  

  change file attributes on a Linux second extended file system,改变存放在ext2文件系统上的文件的属性
  

  模式共有8种。
  a:让文件或目录仅供附加用途。
  b:不更新文件或目录的最后存取时间。
  c:将文件或目录压缩后存放。
  d:将文件或目录排除在倾倒操作之外。
  i:不得任意更动文件或目录。
  s:保密性删除文件或目录。
  S:即时更新文件或目录。
  u:预防以外删除。
  

  象征性的模式为:+-=(加减等)号,加上相应的属性
  +-=
  

  append only (a),
  compressed(c),
  nodump(d),
  immutable(i),不可变的
  datajournalling(j),
  securedeletion(s),
  no tail-merging (t),
  undeletable (u),
  no atime updates (A),
  synchronous directory updates (D),
  synchronousupdates(S),
  and top of directory hierarchy (T).
  

  参数说明
  -R:递归处理
  -V:显示详细的过程
  +<属性>开启文件或目录的该项属性。
  -<属性>关闭文件或目录的该项属性。
  =<属性>指定文件或目录的该项属性。
  实例:
  加了+i的属性,防止文件被修改,对一些保密性的文件进行这个操作,将会起到很好的效果,如可以对/etc/passwd文件加这个属性,其他人只能查看
# ll
总计 20
-rw-r--r-- 1 root root 39 08-24 01:17 1.txt
-rw-r--r-- 1 root root0 08-24 01:28 2.txt
-rw-r--r-- 1 root root 39 08-24 01:20 3.txt
# chattr +i 1.txt
# vim 1.txt
  

  
页: [1]
查看完整版本: linux之chattr命令