Cannot su in to user accounts. Error "No such file or directory"

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.3

Issue

Customer trying to su as root user accounts and it failed with the error below :

[datacenter@localhost log]$ su - root
Password:: No such file or directory

same error occurs if try to su as user x.

[datacenter@localhost log]$ su - x
Password:
: No such file or directory

Not even able to ssh as the user root.

Resolution

This issue happen because customer edited the /etc/passwd from a Window environment.
Noticed /etc/passwd file had DOS line endings.

For example when we use vi editor to open /etc/passwd file following were noticed :

vi /etc/passwd
root:x:0:0:root:/root:/bin/bash^M

The ^M should not be there and is likely introduced by editing on a Windows platform (although there could be other explanations).

In order to fix the issue remove ^M at the end of each line in /etc/passwd file.

Root Cause

Attempting to edit Red Hat configuration lines from Windows add ^M at end of line.
Windows line ending charactors are different to linux line ending charactors.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.