Checkmk 2.0 is here! See what's new.

Your requirement

You want to change the password of root or another user by using a script. This should be performed without the need for user interaction.

A solution

The passwd command reads the password from the standard input if you specify the --stdin option. Examples:

root@linux# echo 'geheim' | passwd --stdin root
root@linux# echo '73/3g78' | passwd --stdin mk


This procedure may involve security risks, as the password is transferred in clear text. Among other things, the password will be visible:

  • in the Bash history, if you enter the command interactively
  • for a short time in the process list (command ps ax)

However, this solution may still be suitable, for example, if no other users are logged on to the machine at the time of the password generation.

Linux knowledge

These articles were written by the founder of Checkmk many years ago.
They are still valid though and thus we keep them on our website.
Mathias has since then developed a monitoring software called Checkmk

Find out more