-1

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.

Vitamin
  • 21
  • 4
  • This looks very odd. xargs splits each argument from the first line and and run passwd with that as an input. that would never work. read the man page of passwd. and maybe https://unix.stackexchange.com/questions/567376/how-to-change-your-linux-password-via-a-bash-script can help you. – b10n1k Jan 29 '23 at 08:06

1 Answers1

0

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
ramsay
  • 3,197
  • 2
  • 14
  • 13