I unfortunately used a suggestion by bing AI before reading this:
Difficulty: ★★☆☆☆
Implications to consider
Configuration file may no longer work as expected.
Scripts and service units relying on the old username.
Symlinks may point to invalid destinations.
The easy way
Backup your important files.
Create a new user
a. Standard useruseradd -mUG <new_user_name>
b. Admin useruseradd -mUG lp,network,power,wheel <new_user_name>
Remove the previous user and the user’s homeuserdel -rf <old_user_name>
Restore the files to the new user.
The hard way
Us…
The Username changed after I did the following
sudo nano /etc/passwd
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
.
system
Closed
16 August 2023 04:44
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.