linux 输入密码命令,linux密码口令命令passwd

实验操作系统:redhat-as4、as5

自己使用重定向方案写的简单的更改用户密码口令脚本:

[root@webtoto /]# cat aa.sh

passwd nmg001 << EOF

nmg001

nmg001

EOF

[root@webtoto /]#

在as5系统上能够顺利执行,可是在as4上就会报错:

as5:

[root@dmtzlk ~]# sh aa.sh

Changing password for user bjj001.

New UNIX password: BAD PASSWORD: it does not contain enough DIFFERENT characters

Retype new UNIX password: passwd: all authentication tokens updated successfully.

[root@dmtzlk ~]#

as4:

[root@webtoto /]# sh aa.sh

Changing password for user nmg001.

New UNIX password: Retype new UNIX password: Sorry, passwords do not match

New UNIX password: BAD PASSWORD: it is WAY too short

Retype new UNIX password: No password supplied

No password supplied

No password supplied

passwd: Authentication token manipulation error

[root@webtoto /]#

最后在论坛里发帖,经过一个高人指点,原来是两个操作系统对于passwd命令的标准输入控制不一样,rh4的passwd默认是不允许标准输入的,而rh5是允许的,因此才会产生我这样的问题。

在as4操作系统下对脚本里passwd加上参数--stdin,问题解决:

[root@webtoto /]# cat aa.sh

passwd --stdin nmg001 << EOF

nmg001

nmg001

EOF

[root@webtoto /]# sh aa.sh

Changing password for user nmg001.

passwd: all authentication tokens updated successfully.

[root@webtoto /]#

--stdin参数含义:

--stdin

This option is used to indicate that passwd should read the new

password from standard input, which can be a pipe.

知识点: 标准输入的重定向,passwd用法。

为什么两个版本系统的passwd命令默认参数不一样呢?应该是有类似于配置文件或者环境的地方做了控制,到目前还没有找到。需要继续研究。

问题原帖:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值