shell脚本中的passwd命令

发布于 2024-10-07 07:22:46 字数 101 浏览 0 评论 0原文

我正在制作一个自动创建用户的 shell 脚本,但我不知道如何在 shell 脚本中使用 passwd 命令,我应该如何将它与 shell 脚本一起使用? --stdin 选项对我不起作用

I am making a shell script that automatically create users, but I cannot think of how to use passwd command within my shell script, how should I use it with shell script? --stdin option doesn't work for me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

两人的回忆 2024-10-14 07:22:46

passwd 的某些实现具有 --stdin 标志,您可以像这样使用它:

passwd --stdin user <<<"SoMePasSw0rd"

Some implementations of passwd have the --stdin flag which you can use like so:

passwd --stdin user <<<"SoMePasSw0rd"
寄与心 2024-10-14 07:22:46

在 Debian 上为我工作

echo -e "$NEWPASS\n$NEWPASS" | passwd $USER

Works for me on Debian

echo -e "$NEWPASS\n$NEWPASS" | passwd $USER
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文