Scripting the Linux ‘passwd’ command easily without interactive prompt

linux, shell bash, ubuntu

If you are looking for a quick and easily solution to changing your Linux passwd from a script, you have come to the right place. As you already know, the passwd command prompts the user to enter the desired password as well as a confirmation, but I have a solution that will change the password without these prompts.

Changing Linux Password In a Scriptable Way

echo <Desired Password> | passwd --stdin root

That’s all there is to it! No fancy bash script, no need to use Expect.

See also  Find large files on Linux: 5 Command-line Examples

Support us & keep this site free of annoying ads.
Shop Amazon.com or Donate with Paypal

1 thought on “Scripting the Linux ‘passwd’ command easily without interactive prompt”

  1. It’ll be better if there are some explaination of the commands, options, and prerequisite. for example, the passwd –stdin command will only work with root ID.

Leave a Comment