Unable to login as user after editing passwd file

Helllo, today I did something very stupid. The stupid thing being: following the ‘tutorial’ at HowTo: Grant Root Access to User - Root Privileges - Linux - ShellHacks without reading the comments. In that ‘tutorial’, the writer suggests changing the UID and the GID of a user to 0 to give them root access. In my case, doing this and restarting the system did nothing much except cause me to be unable to use most programs (root cannot use them). To undo this, I set the UID and the GID back to what they were (1000). After restarting however, trying to log into this user makes my computer freeze. I am still able to log into root, and setting the UID of that user back to 0 ‘fixes’ this problem. Is there any (simple) way I can undo this? Thanks in advance.

If you are able to do that:
set a new password for root and the user

the command to do that is …
passwd $user_name

keep the terminal with root access open

open another one to test whether your intervention worked
by trying to log in there

or test it in a TTY for fresh logins

… keep the terminal with root access open until you confirmed to have fixed the issue

So as far as I can tell, this changed nothing much. Filling in the new password now freezes the system. Trying to fill in the old returns ‘login failed’, so the passwd command does do something. Probably important to clarify though: I do not just have a terminal with root open, I am logged in as root.

I’m guessing you didn’t make a backup of that file?

That’s correct… I did notice that the original values were 1000 though, and I verified that for the GID by looking at etc/group. So unless there were changes made by the system to the passwd file, it should be in its original state.

I’ve tried to make a new user, and see what happens when I log into this second user. Trying to log into that user results in a split second black screen and does nothing otherwise (no freezing either). It seems to me that something’s quite wrong with password authentication after doing this…

Okay, I think I found the problem. Somehow xorg was failing to start the GUI when logging in with any other user than those with a UID equal to 0. I was able to access the TTY for those users (ctrl + alt + F5 in the lock screen), and removing etc/X11/.Xauthority and letting xorg remake it seems to have solved the issue.

Have you not heard of sudo?

2 Likes

Using btrfs, creating a backup before making any changes to the system has never been easier.
Take a snapshot with btrfs, then you can compare your changes afterwards and undo everything (or details)!
:footprints:

You can find good Information about Btrfs in the wiki

Yes I have; I wanted to use some GUI application with root privileges without having to start it from the terminal with sudo. In my case root and the user had the same password, so I did not think it’d be that much of an issue if that user had root privileges, so I checked if that was possible, and this ensued.

Much safer way is add command to NOPASSWD in sudoers and create alias:

alias command='sudo command'
2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.