Linux学习-chattr和umask

#选项只有root用户才可以设置
#通过-i选项,文件将不能删除,修改,改名,设置链接
[root@base tmp]# chattr +i file1
[root@base tmp]# lsattr file1
----i----------- file1
[root@base tmp]# rm -rf file1
rm: cannot remove ‘file1’: Operation not permitted
[root@base tmp]# echo addfile1 >> file1
-bash: file1: Permission denied
#通过-a选项,文件不能被删除,修改,只能追加数据
[root@base tmp]# chattr -i file1
[root@base tmp]# lsattr file1
---------------- file1
[root@base tmp]# chattr +a file1
[root@base tmp]# lsattr file1
-----a---------- file1
[root@base tmp]# echo addfile2 >>file1
[root@base tmp]# cat file1
first file1
addfile2
[root@base tmp]# echo addfile3 > file1
-bash: file1: Operation not permitted
[root@base tmp]# rm -rf file1
rm: cannot remove ‘file1’: Operation not permitted
umask

目前用户在建立文件或目录时的权限默认值

[root@base tmp]# umask
0022
[root@base tmp]# umask -S
u=rwx,g=rx,o=rx
#1.用户创建文件时默认没有可执行(x)权限,也就是最大666,默认权限为-rw-rw-rw-,创建文件时,使用666-022即644
#2.用户创建目录时,由于x与是否进入目录有关,因此最大权限为777,默认为drwx-rwx-rwx,使用777-022即755
#在/etc/bashrc文件中查看umask的设置
 70     if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
 71        umask 002
 72     else
 73        umask 022
 74     fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值