linux - 创建用户帐户时缺少命令提示符用户名 - Linux - Debian?
问题描述
我正在编写一个 bash 脚本来创建带有密码的用户帐户,该密码将过期。创建用户帐户然后使用 su - 登录后,我收到提示,但提示中缺少用户 ID。此外,缺少选项卡自动完成功能。这是我的 bash 脚本。请记住,我在 Windows - WSL2 中使用 Debian 9。
#!/bin/bash
# This script creates an account on the local system.
# You will be prompted for the account name and password.
# Ask for the user name.
read -p 'Enter the username to create: ' USER_NAME
# Ask for the real name.
read -p 'Enter the name of the person who this account is for: ' COMMENT
# Ask for the password
read -p 'Enter the password to use for the account: ' PASSWORD
# Create the user
useradd -c "${COMMENT}" -m ${USER_NAME}
# Set the password for the user.
# echo ${PASSWORD} | passwd --stdin ${USER_NAME}
echo "${USER_NAME}:${PASSWORD}" | chpasswd
# Force password change on first login.
passwd -e ${USER_NAME}
运行此程序后,我会在左侧收到一个提示,其中没有用户 ID。此外,使用选项卡的自动完成功能不起作用。我有点惊讶,我在这里做错了吗?
这就是我所看到的。
解决方案
使用 adduser 命令而不是 useradd 添加用户。Inscript 总是用户 adduser。在 Debian 盒子上测试了相同的脚本,它工作正常。
推荐阅读
- cuda - Invalid resource handle returned from cudaLaunchKernel when using non-default GPU
- qt - QML Controls overlapping
- django - 如何使用子 json 数据在 Extjs 中创建树面板
- python - 在 Python Sphinx 的 autodoc 中更改模块的名称
- java - 如何为 JMenu 设置布局?
- android - 在 ImageView 中放置许多 TextView
- material-ui - 自定义图标
组件 - powershell - 搜索文件时可以在目录路径中使用 %username% 吗?
- r - 检查两列的条件,如果为真,则操作 R 中的第三列
- c++ - 对于相同的精确计算,无法解释的不同 omp_get_wtime()