Search code examples
shellpasswordsubuntu-16.04

Change user password with one Bash command line


I am making a program with Python 2.7, I use shell commands to create new users on Ubuntu and I want to setup the password for the new user. I use command prompt (Bash) commands to create users. Is there a command line that would change user's password just with 1 shell command? I tried:

echo "newpass" | passwd --stdin user1 

but it appears the current Ubuntu 16.04 version I have doesn't have the --stdin parameter anymore. And I need that after the command is executed, the password would be set, I would not need to retype to confirm password etc (like using terminal).


Solution

  • echo 'user:passwd' | sudo chpasswd
    

    This helped me.