linuxubuntuxargspasswd

how to change user password in ubuntu using xargs


I need to change the password of "vtm" user to "abcd12345" by using xargs command.

so I wrote this comman

printf "vtm abcd12345 abcd12345" | xargs -t -n1 passwd

but I couldn't change it.


Solution

  • You could use chpasswd command to change password instead.

    # 1. find the user id of `vtm`
    > sudo grep "vtm" /etc/passwd.
    
    # 2. change password with `chpasswd`
    echo 'userid:abcd12345' | chpasswd
    

    Or if you want to change password with echo:

    echo -e -n "abcd12345\nabcd12345" | passwd vtm