What happpens to /etc/passwd- file when useradd command fails

0

I know that when a user is added using the useradd command, it creates a backup of /etc/passwd in /etc/passwd-, and then add the new user into the /etc/passwd. Suppose if by some chance the useradd command fails to add new user to /etc/passwd file, will the content of /etc/passwd and /etc/passwd- file be same or will the /etc/passwd- file be rolled back to the original content before adding the new user?

LinuxPenseur

Posted 2011-10-27T11:37:02.903

Reputation: 191

Answers

0

I'm afraid the only way to be sure about the answer, here, is to look at the source. Because, even if you could find a way to cause it to fail, different failures might incur different actions. That being said, the most logical course of action would be simple: use the extant /etc/passwd file. If it hasn't made the change, no problem; if it has, it's committed. It's pretty close to atomic.

ravenpi

Posted 2011-10-27T11:37:02.903

Reputation: