I wanted to change the name before hostname on my Ubuntu terminal (the x
in x@y
)
To do so I replaced old x
in /etc/passwd
and /etc/shadow
with newname
Now when I am trying to open Ubuntu, its not opening up; it is redirecting me to lock screen
That's because a username mustn't be change manually (it's not about just changing username inside
/etc/passwd
and/etc/shadow
files); the/home
directory wasn't created, so it didn't find where it can login, and finally return to the login screen in order to say at user that he must fix this issue. Here are differents ways to fix that :Connect using
tty
console :tty
terminal/etc/passwd
and/etc/shadow
filessudo usermod -l newUsername oldUsername
command to change the old usernameoldUsername
with a new onenewUsername
everywhere neededIf you can't connect to a login using the
tty
console/etc/passwd
and/etc/shadow
filessudo usermod -l newUsername oldUsername
command to change the old usernameoldUsername
with a new onenewUsername
everywhere neededIf no one of these methods works, then you can try to restore username by using a live session
use this following commands to mount your partition :
/etc/passwd
and/etc/shadow
filessudo usermod -l newUsername oldUsername
command to change the old usernameoldUsername
with a new onenewUsername
everywhere neededIf no one of these methods works (I really doubt), I couldn't help more
Both
/etc/passwd
and/etc/shadow
are not meant to be edited manually / with a text editor.This won't help you much, but in order to change your username you should have used the
usermod
command.I can think of two possible solutions:
If you have another user on your system, log in, and revert the changes you did on both mentioned files.
Use a bootable medium, like an USB stick or a CD-ROM with Linux, boot your PC and mount the hard drive of your installed Linux. Then revert the changes.