Unable to Login after editing the etc/passwd file LM17
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Unable to Login after editing the etc/passwd file LM17
Hi there,
I am back with my problems again. Kindly help me.
My system specifications: Samsung RV509, i3, 300GB HDD, 3GB Ram, Dual boot Windows7 & LM 17 cinnamon qiana.
I am the Root.
What I did?
I manually edited the 'etc/passwd' file to change three UIDs from 1000, 1001 & 1002 to 999, 998 & 997.
Why I did it?
When I or any other users tried to login, I wanted that the Login prompt should appear instead of the user list appearing by default.
What was the result?
After editing the etc/passwd file I opted for a 'New Login' and accordng to my wishes the user list did not appear and I got the Login prompt. I was delighted. However to my misfortune, when I restarted the system I was not able to Login. The Login promt appeared but when I entered my ID & Password I got an error message. It appeared only once and I didn't bother to save it assuming that I could revert back to the backed up etc/passwd file and could resolve the issue. The error message said something about the 'home/.dmrc' and XSession and mentioned something like 'the user should have 644 permissions and others should not be able to authorised'.
When I couldn't login, I restarted the system with the LiveUSB and copied back the backed-up 'etc/passwd' file and tried to login again but I started recieving an error message persistently. [which I have enclosed herewith].
Enclosure: Kindly forgive the quality of the image of the error report. I had to take several snaps of the long report, with my mobile phone and join them by cutting & pasting. Thank you.
Error message-
How I tried to resolve?
I Logged in with my Live-USB. Mounted the 'Root-partition' with the help of the DISKS application and opened the file system as Root. Replaced with the backed up file once and Re-edited twice the etc/passwd file, saved and exited. But when I restarted the system the problem was persistant.
Please kindly help me resolve this issue. I would be greatful to you.
I logged in with LiveUSB. Opened the terminal. Typed 'sudo adduser user1', hit enter, I was asked to enter new password. I entered. Then accepted the defaults. Did the same for 'sudo adduser user2' & 'sudo adduser user3'. Then restarted the system. I got the Login screen and was prompted for login name & password. I entered. I got the below error message; [I had got this error earlier too. The one that I had ignored to save then.]
I restarted again. This time I got the same error report that I have attached in my last post.
Thank you manu-tm for the suggestions and the link,
I did as suggested.
When in the recovery mode I gave the 'adduser' command for the User1, user2 and the user3 it returned as 'the user already exists' for all the three users. Then I exited and restarted. However the problem persisted. I got the same error message as posted in #1.
Why I did it?
When I or any other users tried to login, I wanted that the Login prompt should appear instead of the user list appearing by default.
I'm not sure what you want to do. You want to be able to type the user name first?
Anyways, manually changing UIDs in /etc/passwd is likely to break something. Maybe you could have a look at the adduser man page and check out home dir options (and other ones as well).
When in the recovery mode I gave the 'adduser' command for the User1, user2 and the user3 it returned as 'the user already exists' for all the three users.
You can't create users with existing names.
As root:
Create new users with unique name and set unique password.
Try to login as new user and test it. If all seems good, do the same for other users.
Once you system became usable, you can remove old users and their home directories.
Your problem is a mismatch between your new user numbers and the user number kept in each file and directory to show the ownership of the file or directory. You changed 'etc/passwd' file to change three UIDs to 999, 998 & 997. However you left all of the files and directories owned by those users as being owned by users 1000, 1001 & 1002. So the new UIDs cannot access the files still owned by the old UIDs.
You could fix the problem by logging in as root and using the chown command to make the file and directory ownerships correspond to the new UIDs.
What I did?
I manually edited the 'etc/passwd' file to change three UIDs from 1000, 1001 & 1002 to 999, 998 & 997.
You have to be careful when manually editing files as it can effect other settings/files in the system. The proper way is to use the usermod command to change the users ID's. This would have also updated any settings/files in the system to reference the change.
If curly, larry, and moe ID's were 1000, 1001, 1002 respectively, the above codes would change the old ID's in the /etc/passwd file to the new ID's of 999, 998 and 997.
I'm not sure it's going to work now because the damage has been done. But you can use the code in the future to properly change the user's ID.
Last edited by sounds greek 2 me; 12-13-2014 at 05:16 PM.
Try to login as new user and test it. If all seems good, do the same for other users.
Once you system became usable, you can remove old users and their home directories.
Hello Teufel,
Thank you for coming.
I tried as suggested in recovery mode. But when I restarted, even before the Login screen is loaded a message was displayed that said 'Keys: Press S to skip mounting or M for manual recovery'. I pressed S. Nothing happened. I pressed M. The command prompt appeared. I repeated again the steps you suggested and created another new user and exited and restarted. But again the message appeared saying 'Keys: Press S to skip mounting or M for manual recovery'. This time I pressed only M and created another user and exited and restarted. But again the same message appeared.
Your problem is a mismatch between your new user numbers and the user number kept in each file and directory to show the ownership of the file or directory. You changed 'etc/passwd' file to change three UIDs to 999, 998 & 997. However you left all of the files and directories owned by those users as being owned by users 1000, 1001 & 1002. So the new UIDs cannot access the files still owned by the old UIDs.
----------------------
Steve Stites
Thank you jailbait for coming,
Nice diagnostic explaination. That explains it all. Yes this is what might have happend in my case.
Quote:
Originally Posted by jailbait
You could fix the problem by logging in as root and using the chown command to make the file and directory ownerships correspond to the new UIDs.
----------------------
Steve Stites
Forgive my ignorance. Could you please give me a step by step guidance as to how to do this?
You have to be careful when manually editing files as it can effect other settings/files in the system. The proper way is to use the usermod command to change the users ID's. This would have also updated any settings/files in the system to reference the change.
If curly, larry, and moe ID's were 1000, 1001, 1002 respectively, the above codes would change the old ID's in the /etc/passwd file to the new ID's of 999, 998 and 997.
I'm not sure it's going to work now because the damage has been done. But you can use the code in the future to properly change the user's ID.
Thank you sounds greek 2 me, for coming.
I tried the 'usermod' as suggested in the recovery mode. But as you said the damage has been done. It didn't work.
Yes, really I shouldn't have done manual editing with my kind of ignorance of the OS. I took suggestions from the web and tried somethings earlier. Since they didn't work, I tried this reckless thing.
Thank you for the information and caution sounds greek 2 me.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.