Search code examples
unixchange-password

Does 'echo user:pass | /usr/sbin/chpasswd' override the root password?


On a work server I server I created a new user called Dev-admin. This user has Root permissions. The password was incorrect and needed to be changed.

I ran the chpasswd command as seen below to change it

 echo user:pass | /usr/sbin/chpasswd

This was successful, however, when I changed users with su - Dev-admin the user displayed was:

root@domain instead of Dev-admin@domain

Is this only because Dev-admin has root privileges? I am afraid that I changed the original root password instead of just the Dev-admin one.


Solution

  • It is possible that Linux does not recognize your username as a username in the command but as part of the command and fails to execute your username as part of the command and instead executes su - instead and returned with root@domain because your username has one of these symbols ., - and _ and is referred to as a BadName in Linux. Try changing your username to a different name, like for example, instead of Dev-admin, try using devadmin instead. So don't be afraid, you didn't change the password of the root user.