我正在尝试创建一个创建新用户的 bash 脚本。我将所需的用户名作为参数传递,但它不接受该值。
我正在尝试:
root@forgehe:~# bash newuser.sh userexample
创建一个名为“userexample”的用户,但是我收到错误:
adduser: To avoid problems, the username should consist only of
letters, digits, underscores, periods, at signs and dashes, and not start with
a dash (as defined by IEEE Std 1003.1-2001). For compatibility with Samba
machine accounts $ is also supported at the end of the username
我的bash脚本:
#!/bin/bash
DESIREDUSERNAME=$1
sudo adduser --disabled-password --gecos "" $DESIREDUSERNAME
我对 bash 和 linux 还很陌生,所以我提前道歉