[root@test ~]# cat 1.txt #!/bin/bash # $1指的是脚本后的第一个参数(输入的用户名:test),$2是脚本后的第二个参数(输入的密码:123) useradd "$1" echo "$2" |passwd --stdin "$1" [root@test ~]# ./1.txt test 123 Changing password for user test. passwd: all authentication tokens updated successfully.