您的位置:首页 > 其它

useradd 无法打开密码文件

2011-07-19 23:54 155 查看
老问题了,以前在某论坛写过帖子,但是找不到了,现在记在这。。。。
造成这个现象的原因是/etc/passwd文件的ext2文件属性被修改(但即便是在ext3系统中,这个属性也有效果。目前还没在ext4文件系统中测试)。使用lsattr可以查看该文件的属性:
[root@RHEL ~]# lsattr /etc/passwd
----i-------- /etc/passwd
该文件被设置了"i"属性,该属性指定当前文件不可被修改,在手册中对此属性的描述为(man chattr):
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.  Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability
can set or clear this attribute.
使用chattr去掉相关文件的"i"属性(我的系统中,/etc/shadow也被设置了"i"属性):
[root@RHEL ~]# chattr -i /etc/passwd
[root@RHEL ~]# chattr -i /etc/shadow
这样,就可以添加用户了。另外,虽然不知道是谁,或者哪个程序设置了"i"属性,但是此属性对系统安全还是有一定用途的,建议添加用户后将文件的"i"属性再设置上。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐