Thomas' Tech Tips

Change system user's password from shell

21 April 2025 - Thomas Damgaard

When automating various deployment or bootstrapping processes, it is handy to be able to set a user’s password from the command-line or from a shellscript. Typically, this is done immediately after user creation.

This is an easy way of doing it:

echo username:secret | chpasswd

Of course, the regular security warnings apply: the password will be in the shell history, password will be visible in the process list, etc. so think before using.

Filed under: bash, howto, linux, security, shell, tips

Back to article list