造成这个现象的原因是/etc/passwd文件的ext2文件属性被修改(但即便是在ext3系统中,这个属性也有效果。目前还没在ext4文件系统中测试)。

使用lsattr可以查看该文件的属性:

useradd 无法打开密码文件

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"属性:

useradd 无法打开密码文件

这样,就可以添加用户了

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-08-01
  • 2021-10-17
  • 2021-07-23
  • 2021-07-10
  • 2021-07-24
猜你喜欢
  • 2021-12-03
  • 2021-11-17
  • 2021-11-17
  • 2021-09-16
  • 2021-06-03
  • 2021-06-17
  • 2022-12-23
相关资源
相似解决方案