Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Oct 28 '11 at 22:50

This question came from our site for professional and enthusiast programmers.

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .