【问题标题】:adduser: Specify only one name in this modeadduser:此模式下只指定一个名字
【发布时间】:2014-03-03 15:01:03
【问题描述】:

我正在尝试使用此命令添加用户:

#!/bin/bash

APPUSER="test1"
APPGROUP="test2"

# User
adduser -c 'uwsgi user' --group $APPGROUP --system --no-create-home --disabled-login --disabled-password $APPUSER

但是它告诉我我只能指定一个名称,但就我所见,我只指定一个名称。

怎么了?

【问题讨论】:

  • 你的脚本有 DOS 行尾吗?它可能会将APPUSER 值中的尾随回车符和/或对adduser 的调用结束时解释为附加用户名。 bash 不会将 \r 视为空格。

标签: linux bash shell debian


【解决方案1】:

将--group更改为--gid

并像这样按组名查找 id:

APPGROUP=`grep "test2" /etc/group|cut -d: -f3`

adduser -c 'uwsgi user' --gid $APPGROUP --system --no-create-home --disabled-login --disabled-password $APPUSER   

【讨论】:

    猜你喜欢
    • 2012-10-31
    • 2012-02-03
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多