Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Oct 28 '11 at 22:50

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

add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.