Production environment configuration:
Operating system: CentOS 6.6
1. The problem arises:
"SERADD:CANNOTOPEN/ETC/PASSWD" appears when you add an account using the Useradd command
[[Email protected] ~] #useradd-D/home/wwwroot/ftupuser-g ftp-s/sbin/nologin Ftpuser
useradd:cannotopen/etc/passwd
2. reasons for the resulting:
a) After adding the "I" hidden property, the file cannot be changed.
[[Email protected] ~] #chattr +i/etc/passwd
[[Email protected] ~] #chattr +i/etc/shadow
[[Email protected] ~] #chattr +i/etc/group
[[Email protected] ~] #chattr +i/etc/gshadow
b) The last time you use SSH to telnet to the "change" to half is a power outage, restart, or some programs also need to access the properties of a particular file.
3. problem Solving:
[email protected] ~] #chattr-I/etc/passwd
[[Email protected] ~] #chattr-I/etc/shadow
[[Email protected] ~] #chattr-I/etc/group
[[Email protected] ~] #chattr-I/etc/gshadow
through the above approach, there is no problem solved. the "lsattr" command to further review the related properties, found that there is a "chattr +a" permission attribute is not removed, so the right to operate.
[[Email protected] ~] #lsattr/etc/passwd
-----a-------e-/etc/passwd
[[Email protected] ~] #lsattr/etc/passwd
-----a-------e-/etc/passwd
[[Email protected] ~] #lsattr/etc/shadow
-----a-------E-/etc/shadow
[[Email protected] ~] #lsattr/etc/group
-----a-------E-/etc/group
[[Email protected] ~] #lsattr/etc/gshadow
-----a-------E-/etc/gshadow
[[Email protected] ~] #chattr-a/etc/passwd
[[Email protected] ~] #chattr-a/etc/shadow
[[Email protected] ~] #chattr-a/etc/group
[[Email protected] ~] #chattr-a/etc/gshadow
[[Email protected] ~] #lsattr/etc/passwd
-------------E-/ETC/PASSWD
[[Email protected] ~] #lsattr/etc/shadow
-------------E-/etc/shadow
[[Email protected] ~] #lsattr/etc/group
-------------E-/etc/group
[[Email protected] ~] #lsattr/etc/gshadow
-------------E-/etc/gshadow
[[Email protected] ~] #useradd-P/home/wwwroot/ftpuser-g ftp-s/sbin/nologin Ftpuser
[[Email protected] ~] #useradd-P/home/wwwroot/ftpuser-g ftp-s/sbin/nologin Ftpuser
Useradd:user ' Ftpuser ' already exists
solve the problem by doing the above.
This article is from the "linux~dba~mba~edu" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1698416
Why the Linux system cannot add user accounts for analysis