博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
文件隐藏属性: chattr, lsattr
阅读量:2046 次
发布时间:2019-04-28

本文共 1189 字,大约阅读时间需要 3 分钟。

Linux文件的隐藏属性在保护系统文件的安全性上非常重要。先强调的是,chattr命令只能在Ext2/Ext3的文件系统生效。

chattr(设置文件的隐藏属性)

[root@www ~]# chattr [+-=] [ASacdistu] File/Directory

参数

+:增加某个参数

-:删除某个参数

=:仅有后面接的参数

各个参数的意思

参数 含义
A 设置A属性后,若你访问此文件或目录时,它的访问时间atime不会被修改,可避免I/O较慢的机器过度访问磁盘。这对速度较慢的计算机有帮助。
S 一般文件是异步写入磁盘,加上S属性后,文件将同步写入磁盘
a 当设置a后,文件只能增加数据,既不能删除也不能修改数据,只有root才能设置这个属性
c 设置c属性后,会自动将文件压缩,在读取时自动解压缩
d 当dump程序执行时,设置d属性将可使改文件或目录不被dump备份
i i属性可使文件不能被删除、改名,设置连接也无法写入或添加数据。对于系统安全性有很大帮助。只有root能设置此属性。
s 当文件设置s属性时,如果文件被删除,将从硬盘彻底删除
u 与s相反,当文件设置u属性时,文件删除后数据内容还存在磁盘,可以使用来找回该文件
j A file with the `j' attribute has all of its data written to the ext3 journal before being written to the file itself, if the  filesystem  is mounted with the "data=ordered" or "data=writeback" options. When the filesystem is mounted with the "data=journal" option all file data is already journalled and this attribute has no effect. Only the superuser or a process possessing the CAP_SYS_RESOURCE capability can set or clear this attribute.

 

lsattr(显示文件隐藏属性)

[root@www ~]# lsattr [-adR] File/Directory

参数

-a:将隐藏文件的属性也显示出来

-d:如果接的是目录,仅列出目录本身的属性而不是目录内的文件名

-R:连同子目录的数据也显示出来

使用范例

[root@www ~]# chattr +aij attrtest

[root@www ~]# lsattr attrtest

----ia---j---    attrtest

 

转载地址:http://qblof.baihongyu.com/

你可能感兴趣的文章
(PAT 1145) Hashing - Average Search Time (哈希表冲突处理)
查看>>
(1129) Recommendation System 排序
查看>>
PAT1090 Highest Price in Supply Chain 树DFS
查看>>
(PAT 1096) Consecutive Factors (质因子分解)
查看>>
(PAT 1019) General Palindromic Number (进制转换)
查看>>
(PAT 1073) Scientific Notation (字符串模拟题)
查看>>
(PAT 1080) Graduate Admission (排序)
查看>>
Tree UVA - 548 (DFS+建立二叉树)
查看>>
Play on Words UVA - 10129 (欧拉路径)
查看>>
mininet+floodlight搭建sdn环境并创建简答topo
查看>>
(计蒜客) 取石子游戏 (gcd算法灵活运用)
查看>>
Prime Path POJ - 3126 (BFS,素数距离)
查看>>
Wireless Network POJ - 2236 (并查集)
查看>>
【javascript】手写bind函数
查看>>
Kube-state-metrics的collectors配置
查看>>
使用Vmware装虚拟机Ubuntu
查看>>
【java】异常处理及捕获的理解
查看>>
【Java】继承知识点总结
查看>>
【Linux】什么是链接文件及其分类
查看>>
【UML】《Theach yourself uml in 24hours》——hour2&hour3
查看>>