Rate this page del.icio.us  Digg slashdot StumbleUpon

Tips and tricks: When I am trying to add a user, the following error occurs: mismatch in /etc/passwd and /etc/shadow. What does this mean?

by the editorial team

This can occur when there is inconsistencies between the /etc/passwd and /etc/shadow files. The offending account needs to either be modified or removed. To find out which account is causing the issue run the following command as root:

pwck

All entries in the /etc/passwd and /etc/shadow are checked to see that the entry has the proper format and valid data in each field. The user is prompted to delete entries that are improperly formatted or which have other uncorrectable errors.

An example of an account that is in /etc/shadow but not in /etc/passwd:

no matching password file entry in /etc/passwd
delete line 'someuser:!!:13758:0:99999:8:::'?

Red Hat’s customer service and support teams receive technical support questions from users all over the world. Red Hat technicians add the questions and answers to Red Hat Knowledgebase on a daily basis. Access to Red Hat Knowledgebase is free. Every month, Red Hat Magazine offers a preview into the Red Hat Knowledgebase by highlighting some of the most recent entries. The information provided in this article is for your information only. The origin of this information may be internal or external to Red Hat. While Red Hat attempts to verify the validity of this information before it is posted, Red Hat makes no express or implied claims to its validity.

7 responses to “Tips and tricks: When I am trying to add a user, the following error occurs: mismatch in /etc/passwd and /etc/shadow. What does this mean?”

  1. Artur Szymczak says:

    Hi,
    this is very usefull command. Thx.

  2. Nikolay Kabaivanov says:

    Hi,
    There is another command that do the same, but for the groups - “grpck” !

    Regards
    Nikolay Kabaivanov
    Fashion.bg Ltd.

  3. JJW says:

    Anyone for “pwconv”. It fixes the problem but does not tell you what it does. You can also use “grpconv” for group. They handle NIS(+) entries properly (does nothing).

  4. jth says:

    I tried pwconv on a file that was in /etc/passwd format except the passwords were in plain text. It copied the plain text passwords to shadow and replaced the ones in passwd with an ‘x’. I thought it was supposed to encrypt the passwords. Anyway I finally got the job done using the newusers prog. I didn’t use the same encryption scheme as passwd, but I can still login to the newly established accounts. Can anyone explain what’s going on?

  5. Dinesh says:

    dear sir

    i read linux for u magazine
    in this magazine i read about autologin
    i try to login but not complete
    can you help me how i can auto login

    thanks & regard
    Dinesh kumar

  6. CIO Jerry says:

    ith, pwconv did it by design. It is used to convert old pre-shadow /etc/password to the new shadow-compliant format. That is, no passwords in /etc/passwd, encrypted or otherwise. real passwords were removed from /etc/passwd and replaced with an x, indicating real ones are in /etc/shadow now. Excerpts from pwconv’s man page “pwconv creates shadow from passwd and an optionally existing shadow.”

  7. CIO Jerry says:

    I’d recommend a more cautions process on a real server,
    1) make a copy of the malformed password and shadow file
    cp /etc/passwd /tmp/passwd.bad; cp /etc/shadow /tmp/shadow.bad
    2) run ‘pwck’ against copies instead of the originals.
    pwck /tmp/passwd.bad /tmp/shadow.bad
    3) compare to see what changes were made and whether they make sense. manually adjust as necessary
    diff /etc/passwd /tmp/passwd.bad
    4) schedule a time to put the new set in place, to minimize user impact.

Leave a reply