I change the last line in /etc/passwd and I can't use sudo
Solution 1:
You must NEVER edit your passwd file manually because you will mess things up.
The proper way to change your username is:
usermod -l newUsername oldUsername
Then change home folder:
usermod -d /home/newHomeDir -m newUsername
To change password you should use:
sudo passwd yourusername
I suggest you to revert your passwd file back, or if you can't edit it because you can not login with root - then boot with live cd and revert the file back. Then use the proper way.
Solution 2:
The reason you got stuck after your edit is that the /etc/shadow
file contained an entry for the password of tiny
but no entry for abc
, whereas the /etc/passwd
file contained an entry for abc
and not for tiny
. When sudo
looked, it identified you correctly (according to the password file) as abc
based on the UID of the process you were running, but when it looked to compare what you entered as your password with the encrypted (hashed) password stored in /etc/shadow
, it couldn't find an entry for abc
, so it had to report the failure.
As shaddy said in his answer, don't edit the password or shadow files by hand. If you must break the rule, then edit both in a single invocation of vim
, and don't exit from vim
until you've proved that the changes are sane enough to work by using another terminal window, and do save backup copies of the files before you start hacking them, and do reconsider why you're breaking the rules in the first place, because it probably isn't a good idea.