Users/username
名前と姓、ホームディレクトリがあり、有効期限があり、非アクティブで、DKEL_dirにデフォルトのUIDとGIDを持つユーザーを作成しようとしています/etc/skel2
。これがCentOSで実行されています。
sudo useradd -m -d /Users/username -s /bin/default/useradd -e $(date. -d "2 days ago" "+%Y-%m-%d") -f -k /etc/skel2 Scott walker
私が得た結果は次のとおりです。
useradd:invalid numeric argument '-k'
ベストアンサー1
/Users
なぜ非標準ディレクトリに入れたいのかわかりません。本当にこれをしたいですか? Linuxシステムでは、ホームディレクトリは通常以下にあります/home
。 macOSでのみ見たこと/Users
があり、時にはユーザーを処理する中央サーバーがあることもあります。
とにかく、あなたがそれをしたいと仮定すると/Users
、最初の問題は-f
パラメータが必要であるということです。からman useradd
:
-f, --inactive INACTIVE
defines the number of days after the password exceeded its maximum
age where the user is expected to replace this password. The value
is stored in the shadow password file. An input of 0 will disable
an expired password with no delay. An input of -1 will blank the
respective field in the shadow password file. See shadow(5)for
more information.
If not specified, useradd will use the default inactivity period
specified by the INACTIVE variable in /etc/default/useradd, or -1
by default.
そのため、-f
パスワードの有効期限以降にユーザーが無効になる日数を設定してください。ただし、ここに与えられた値はあなたが書いたので無効であり-f -k
、したがって-k
あなたが与えた値として読み取られます-f
。ユーザーを無効にするには、以前と同様に有効期限を過去に指定してから、自分で-f 0
パスワードを即座に期限切れにします。
次の問題は、ログイン名にスペースを含めることができないため、使用できないことですScott Walker
。名前と姓を設定するには、またはオプションがuseradd
必要です。繰り返しますが、ソース:-c
--comment
man useradd
-c, --comment COMMENT
Any text string. It is generally a short description of the
account, and is currently used as the field for the user's full
name.
次に、-s
シェルはユーザーを定義するために使用され、シェルの代わりにディレクトリ(またはその中にサブディレクトリ)があってはならない/bin/default/useradd
ため、シェルは存在しないでください。何をしたいのかわかりませんが、システムのデフォルトに設定されているシェルを含めてください。したがって、これらすべてを総合すると次のようになります。/bin/default
/bin
-s
sudo useradd -m -d /Users/scott \
-e $(date -d "2 days ago" "+%Y-%m-%d") \
-f -1 \
-k /etc/skel2 \
-c "Scott Walker" \
scott
scott
これにより、Scott Walker
フルネーム、ホームディレクトリ/Users/scott
、有効期限の2日前、昨日の非アクティブな日付で名前が付けられたユーザーが作成されます。
詳細については、次を参照してください。CentOS公式ドキュメント。