Linux · 2009-04-11

shell基础十二篇_学习笔记_1_chmod_date_chattr

权限命令: chmod
1为运行; 2为可写; 4为只读
所以3为可写可运行;5为可读可运行;6为可读可运行;7为可读可写可运行

我按字面意思理解:
u就是user
g就是group
o就是other
a就是all

所以
chmod 777
chmod a+xwr
chmod ugo+xwr
得到的结果会是一样的.

修改时间命令: date
例如修改为 1999年1月1日 01:01 分 [ 可以精确到秒 ]
date -s “1999/01/01 01:01”

debian:~/test# date
2009年 04月 11日 星期六 16:46:33 EDT

debian:~/test# date -s “1999/01/01 01:01”
1999年 01月 01日 星期五 01:01:00 EST

debian:~/test# date -s “2009/04/11 16:50:00”
2009年 04月 11日 星期六 16:50:00 EDT

锁定文件命令: chattr [ 就算是root用户也无法删除 ]
debian:~/test# ls
temp
debian:~/test# chattr +i temp
debian:~/test# rm temp
rm:是否删除有写保护的 一般空文件 “temp”? Y
rm: 无法删除 “temp”: 不允许的操作
debian:~/test# ls
temp
debian:~/test# chattr -i temp
debian:~/test# ls
temp
debian:~/test# rm temp
debian:~/test# ls
debian:~/test#

A file with the ‘i’ attribute cannot be modified: it cannot be deleted
or renamed, no link can be created to this file and no data can be
written to the file