Problems after changing /etc/passwd entry

I unfortunately used a suggestion by bing AI before reading this:

The Username changed after I did the following

  1. sudo nano /etc/passwd
  2. edited the line with the old username, changed it and saved.

Now, my device doesn’t recognize my password when I use sudo. I suspect this might also be a problem if I reboot or log out as it seems the password is no longer recognized.

Please I need help resolving this. Is it possible to reset the change, or get the device to recognize my password?

Welcome,

Please don’t post your support questions in a howto.
I’ve moved your post to a separate thread.

Sure: revert your edit and reboot.

What is it that you wanted to achieve?
Change the user name while keeping the content of the “old” (previous) user intact?

There is a command for that - editing the /etc/passwd file is not the way to go.

So much for the “wisdom” of AI (Bing or any other …)

You’d still very likely have to follow up with manual interventions even after the bulk of the user name change succeeded.

… some paths in some configuration file might still refer to the old name … and thus some things might not work

Just revert the change you made - edit the file again
look into

/etc/passwd-

(note the - at the end of the name)
that is the backup copy of the original file

You could actually just simply copy that one to the original file, replacing it:

sudo cp /etc/passwd- /etc/passwd

… no need to revert the edit

1 Like

Editing /etc/passwd in order to change your login name is not enough. You also need to edit /etc/shadow, /etc/group and /etc/gshadow.

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