0

I was trying to change my username and searching in the internet I’ve found this command:

sudo usermod -l new_username -d /home/new_username previous_username

To apply the changes to all directories.

I ran the command from another user.

But now I can’t log in the principal user back. When I enter the password it keeps returning to the login screem.

How can I revert this miserable changing I’ve done?

stumblebee
  • 4,397
  • You've not mentioned what Ubuntu product/release you're using, It's likely you'd be able to login if a server install (you didn't specify), but with a test done here on a test system here, I'd not expect a GUI login to work, but your OS/release may differ to my system as you've not specified what you're asking about. – guiverc May 13 '24 at 04:43
  • Can you log in as new_username? How about sudo -i? Does that get you a root shell? – terdon May 13 '24 at 10:04
  • You probably should have added the -m option to create the new home directory and copy the old user's files - iirc -d alone does neither, so unless you created /home/new_username graphical login is likely failing because there is no home dir. You should still be able to log in via a CLI virtual terminal (although it will complain and temporarily set the home directory to /). – steeldriver May 13 '24 at 11:33

0 Answers0