Go to main content

マニュアルページ セクション 8: システム管理コマンド

印刷ビューの終了

更新: 2022年7月27日
 
 

roleadd(8)

名前

useradd, roleadd, usermod, rolemod - administer an existing or add a new user or role login to the system

形式

useradd [-A authorization[,authorization...]]
     [-b base_dir | -d dir] [-c 
comment] [-e expire]
     [-f inactive] [-g group] [-G group[,group]...]
     [-K key=value] [-m [-k skel_dir]] [-p projname]
     [-z yes | no | nodelegation]
     [-P profile[,profile...]]
     [-R role [, role...]]
     [-s shell] [-S repository] [-u uid [-o]] username
useradd -D [-A authorization[,authorization...]]
     [-b base_dir] [-s 
shell [-k skel_dir]] [-e expire]
     [-f inactive] [-g 
group] [-K key=value] [-p projname]
     [-P profile[,profile...]]
roleadd [-A authorization[,authorization...]]
     [-b base_dir | -d dir] [-c 
comment] [-e expire]
     [-f inactive] [-g group] [-G group [,group]...]
     [-K key=value] [-m [-k skel_dir]] [-p projname]
     [-z yes | no | nodelegation]
     [-P profile[,profile...]]
     [-s shell] [-S 
repository] [-u uid [-o]] rolename
roleadd -D [-A authorization[,authorization...]]
     [-b base_dir] [-s 
shell [-k skel_dir]] [-e expire]
     [-f inactive] [-g 
group] [-K key=value] [-p projname]
     [-P profile[,profile...]]
usermod [-A authorization[,authorization...]]
     [-d dir] [-c comment] [-e expire]
     [-f inactive] [-g group] [-G group [,group]...]
     [-K key=value] [-m [-k skel_dir]] [-p projname]
     [-z yes | no | nodelegation]
     [-P profile[,profile...]]
     [-R role [, role...]]
     [-l new_username]
     [-q qualifier]
     [-s shell] [-S repository] [-u uid [-o]] username
rolemod [-A authorization[,authorization...]]
     [-d dir] [-c comment] [-e expire]
     [-f inactive] [-g group] [-G group [,group]...]
     [-K key=value] [-m [-k skel_dir]] [-p projname]
     [-z yes | no | nodelegation]
     [-P profile[,profile...]]
     [-l new_rolename]
     [-q qualifier]
     [-s shell] [-S repository] [-u uid [-o]] rolename

説明

The useradd and roleadd utilities add a new user or role entry to the passwd(5), shadow(5), and user_attr(5) databases in the files or ldap repository.

The usermod and rolemod utilities modify a user's or role's login definition on the system.They change the definition of the specified login and make the appropriate login-related changes to the appropriate repository and corresponding file system changes.

The –A and –P options respectively assign authorizations and profiles to the user or role.–R オプションはユーザーに役割を割り当てます。(Roles cannot be assigned to other roles.)The –p option associates a project with a user or role.The –K option adds a key=value pair to the user_attr entry for the user or role.–K オプションを複数使用して、複数の key=value ペアを追加できます。

The –G option creates supplementary group memberships for the user or role.The –m option creates the home directory for the user or role if requested.新しいログインは、passwd(1) コマンドが実行されるまで、ロックされたままになります。

Specifying the –D to useradd or roleadd with the –s, –k, –g, –b, –f, –e, –A, –P, –p, –R, or –K option (or any combination of these options) sets the default values for the respective fields.下記の –D オプションを参照してください。Subsequent useradd or roleadd commands without the –D option use these arguments.

または、実行時に動的に適用されるデフォルト設定を指定できます。–S ldap を使用して作成されるアカウントの場合、いずれかの –K 属性のデフォルト値は、–S ldap および特殊値 default@ をアカウント名として使用して指定できます。default@ アカウントは、ログインに使用することを意図していないため、自動的にロックされます。policy.conf(5) で追加のデフォルト値を指定できます。

useradd and usermod require that usernames be in the format described in passwd(5).これらの要件が満たされていない場合は、警告メッセージが表示されます。

roleadd and rolemod require that role names be a string of no more than eight bytes consisting of characters from the set of alphabetic characters, numeric characters, period (.), underscore (_), and hyphen (-).The first character should be alphabetic and the name should contain at least one lower case alphabetic character.これらの制限が満たされていない場合は、警告メッセージが書き込まれます。A future Solaris release might refuse to accept role names that do not meet these requirements.Role names must contain at least one character and must not contain a colon (:) or a newline (\n).

When used with usermod or rolemod the –A, –G, –K, –P, and –R options may take a list of values to add or remove to the granted set using the [+|-] prefix.A prefix + adds the value to the existing set; a prefix - removes the value from the existing granted set.To remove all values an empty list must be specified using '', or any appropriate equivalent according to the shell in use.

An administrator must be granted the User Management Profile to be able to create a new user or role.既存のユーザーのセキュリティー属性を変更するには、管理者に User Security プロファイルが付与されている必要があります。既存のユーザーのセキュリティー属性以外の属性を変更するには、User Management プロファイルが必要です。The authorizations required to set the various fields in passwd, shadow, and user_attr can be found in passwd(5), shadow(5), and user_attr(5).グループおよびプロジェクトの割り当てに必要な承認については、group(5) および project(5) を参照してください。

オプション

サポートしているオプションは、次のとおりです。

–A [+|-]authorization

auth_attr(5) で定義されている、1 つまたは複数のコンマ区切りの承認。承認の grant 権を持っているユーザーまたは役割だけが、その承認をアカウントに割り当てることができます。

–b base_dir

新しいログインホームディレクトリのベースディレクトリ (下記の –d オプションを参照)。新しいユーザーアカウントが作成されるときは、–m オプションまたは –d オプションも指定されている場合を除き、base_dir がすでに存在している必要があります。

–c comment

任意のテキスト文字列。一般にはログインの簡単な説明文ですが、現在はユーザーのフルネームを表すフィールドとして使用されています。この情報は、ユーザーの passwd エントリに保存されます。

–d dir | server:dir

新しいユーザーのホームディレクトリパスを指定します。サーバー名が指定されていない場合、指定されたディレクトリは passwd(5) データベースで管理されます。

省略可能なサーバー名は、ホストディレクトリがあるホストを指定します。この形式のエントリはオートマウンタに依存し、auto_home マップで管理されます。パス /home/username は、passwd(5) データベースで管理されます。ユーザーが続けて /home/username を参照すると、オートマウンタはここに指定されているディレクトリを /home/username にマウントします。

–D

Display the default values for group, base_dir, skel_dir, shell, inactive, expire, proj, projname, zfshome, and key=value pairs.–g–b–f–e–A–P–p–R、または –K とともに –D オプションを使用すると、指定したフィールドのデフォルト値を設定できます。デフォルト値は次のとおりです。

FIELD
DEFAULT VALUE
group
other (GID of 1)
base_dir
/export/home
skel_dir
/etc/skel
shell
/usr/bin/bash
inactive
0
expire
null
auths
null
profiles
null
auth_profiles
null
proj
3
projname
default
zfshome
yes
key=value (user_attr(5) で定義されているペア))
not present
roles
null
–e expire

ログインの有効期限を指定します。この日付を過ぎると、どのユーザーもこのログインにアクセスできなくなります。expire オプション引数は、テンプレートファイル /etc/datemsk に含まれている日付の形式のいずれかを使用して入力された日付です。See getdate(3C).

選択した日付形式にスペースが含まれている場合は、引用符で囲む必要があります。たとえば、10/6/90 または October 6, 1990 と入力できます。NULL 値 (" ") を指定すると、期限切れのステータスは無効になります。このオプションは一時的なログインを作成する場合に役立ちます。

–f inactive

ログイン ID が最後に使用された日から無効と宣言されるまでの、最大日数を指定します。通常は正の整数です。値 0 を指定すると、このステータスは無効になります。

–g group

既存グループのグループ ID (整数) または名前 (文字列) を指定します。–D オプションが指定されていない場合、新しいユーザーのプライマリグループメンバーシップを定義します。デフォルトでは、デフォルトグループになります。このデフォルト値は、useradd –D –g group を呼び出すことによってリセットできます。0 から 99 の GID は、Solaris オペレーティングシステムによる割り当て用として予約されています。

–G [+|-]group

既存グループのグループ ID (整数) または名前 (文字列) を指定します。新しいユーザーの補助グループメンバーシップを定義します。group–g オプションと –G オプションで重複して指定されている場合、その項目は無視されます。指定できるグループの数は NGROUPS_MAX 以下です。0 から 99 の GID は、Solaris オペレーティングシステムによる割り当て用として予約されています。

–K key[+|-]=value

ユーザーの属性に追加する key=value ペアを指定します。–K オプションを複数使用して、複数の key=value ペアを追加できます。暗黙に指定される特定のキーオプション (–A–P–R–p) の代わりに、汎用の –K オプションと適切なキーを使用できます。使用可能な key=value ペアのリストについては、user_attr(5) を参照してください。type キーは、このオプションに有効なキーではありません。キーを重複して指定することはできません。

–k skel_dir

新しいユーザーのログインのホームディレクトリにコピーできるスケルトン情報 (.profile など) を格納しているディレクトリを指定します。このディレクトリはすでに存在している必要があります。システムには、この目的のために使用できるスケルトンディレクトリとして /etc/skel が用意されています。

–m

新しいユーザーのホームディレクトリが存在していない場合は、新たに作成します。ホームディレクトリがすでに存在している場合、そのディレクトリには group (ユーザーのプライマリグループ) による読み取り権、書き込み権、および実行権が設定されている必要があります。–d オプションに指定されたサーバー名がリモートホストの場合、システムはホームディレクトリの作成を試みません。

When the -z option is not passed and if the directory does not already exist and the parent directory is the mount point of a ZFS dataset, then a child of that dataset will be created and mounted at the specified location.ZFS スナップショットを作成してそれをプロモートするためのアクセス権がユーザーに委任されます。新しく作成されるデータセットは、その親から暗号化設定を継承します。暗号化されている場合は、そのラップ鍵を変更するためのアクセス権がユーザーに委任されます。

新たに作成されるディレクトリは、マルチレベルのデータセットとして作成されます。

–l new_loginname

The new login name for a user or role.Only valid with usermod and rolemod.

–o

重複した (一意でない) UID を許可します。

–P [+|-]profile

prof_attr(5) で定義されている実行プロファイルを 1 つ以上、コンマで区切って指定します。

–p projname

追加するユーザーに関連付けるプロジェクトの名前を指定します。project(5) で定義されている projname フィールドを参照してください。

–q qualifier

拡張された属性 (–K–P–A、および –R オプションで指定される) が適用される対象を修飾するホストまたはネットグループの名前。修飾子がネットグループ名であることを示すには、接頭辞 @ が必要です。The –q option is only valid if the login account is maintained in the LDAP name service.

–R [+|-]role

user_attr(5) で定義されている実行プロファイルを 1 つ以上、コンマで区切って指定します。役割をほかの役割に割り当てることはできません。

–s shell

ユーザーのログインシェルとして使用するプログラムのフルパス名を指定します。指定しない場合は、以前に –D –s オプションで構成された値にデフォルトが設定されます。–D –s でデフォルトが設定されていない場合は、/usr/bin/bash が使用されます。shell の値は有効な実行可能ファイルでなければなりません。

–z zfshome

Select if a new separate ZFS filesystem is created as the user/role home directory.The option can be set as the system wide default or set per user/role.

yes

User has their own ZFS filesystem with the mount, create, and snapshot zfs allow delegations

nodelegation

User has their own ZFS filesystem but with no delegations

no

Users home is a simple directory

–S repository

The repository specifies which name service will be updated.有効なリポジトリは filesldap です。デフォルトのリポジトリは files です。リポジトリが files の場合、承認、プロファイル、および役割が、別のネームサービスリポジトリに存在していても、files リポジトリ内のユーザーに割り当てることができます。When the repository is ldap, all the assignable attributes must be present in the ldap repository, and both the LDAP server and client must be configured with enableShadowUpdate.See ldapclient(8) for details.

–u uid

新しいユーザーの UID を指定します。This UID must be a non-negative decimal integer below MAXUID as defined in <sys/param.h>.UID のデフォルトは、現在割り当てられている最大の値の次に大きい使用可能な (一意の) 値です。たとえば、UID 100、105、および 200 が割り当て済みの場合、次のデフォルトの UID 番号は 201 になります。0 から 99 の UID は、Solaris オペレーティングシステムによる割り当て用として予約されています。

使用例 1 Creating a User

The following command adds adds the user with the default configuration

# useradd jdoe

This results in the system assigning the next available uid, the user will not have a home directory created for them.

使用例 2 Creating a User with a specified uid and create a local home directory

The following command adds adds the user and creates their home directory in the default location

# useradd -u 1001 -m jdoe
使用例 3 Creating a User with a local home directory that is not a ZFS filesystem

The following command adds adds the user and creates their home directory in the default location

# useradd -z no -m jdoe

This results in new user with a directory in the default location as their home directory.

使用例 4 Set the system default for the type of home directory

The following command sets the system wide default to be a directory rather than a per-user ZFS file system as the default home directory type.

# useradd -D -z no
使用例 5 ユーザーへの特権の割り当て

次のコマンドは、高精度の時間に影響を与える特権を、ユーザーの初期の継承可能な一連の特権に追加します。

# usermod -K defaultpriv=basic,proc_clock_highres jdoe

このコマンドにより、user_attr に次のエントリが生成されます。

jdoe::::type=normal;defaultpriv=basic,proc_clock_highres
使用例 6 ユーザーの制限セットからの特権の削除

次のコマンドは、指定されたユーザーがディレクトリへのハードリンクを作成したり、ディレクトリのリンクを解除したりできるようにする特権を削除します。

# usermod -K limitpriv=all,!sys_linkdir jdoe

このコマンドにより、user_attr に次のエントリが生成されます。

jdoe::::type=normal;defaultpriv=basic,limitpriv=all,!sys_linkdir
使用例 7 ユーザーの基本セットからの特権の削除

次のコマンドは、指定されたユーザーがそのユーザーのセッションの外部にあるプロセスを検査できるようにする特権を削除します。

# usermod -K defaultpriv=basic,!proc_session jdoe

このコマンドにより、user_attr に次のエントリが生成されます。

jdoe::::type=normal;defaultpriv=basic,!proc_session;limitpriv=all
使用例 8 ユーザーへの役割の割り当て

次のコマンドは、ユーザーに役割を割り当てます。The role must have been created prior to running this command.

# usermod -R mailadm jdoe

このコマンドにより、user_attr に次のエントリが生成されます。

jdoe::::type=normal;roles=mailadm;defaultpriv=basic;limitpriv=all
使用例 9 ユーザーへのいくつかの権利の付与

次のコマンドは、solaris.zone.manage 承認 (Project Management 権利プロファイル) を付与し、制限特権を基本に設定して、ユーザーに mailadm 役割を割り当てます。

# usermod -A 'solaris.zone.manage' -P 'Project Management' \
     -K limitpriv=basic -R mailadm -S files jdoe_ldap

このコマンドにより、user_attr に次のエントリが生成されます。

jdoe_ldap::::auths=solaris.zone.manage;profiles=ProjectManagement;
limitpriv=basic;roles=mailadm
使用例 10 ユーザーへの認証権利プロファイルの付与

次のコマンドは、信頼できるユーザーに認証権利プロファイルを追加します。

# usermod -K auth_profiles+="Network Security" jdoe
使用例 11 ユーザーからのすべてのプロファイルの削除

次のコマンドは、ユーザーに直接付与されたすべてのプロファイルを削除します。ユーザーは、policy.conf(5)PROFS_GRANTED キーによって付与される権利プロファイルは引き続き保持します。

# usermod -P "" jdoe
使用例 12 Set the root account to be a role

Set the root account to be a role and assign the role to a user.

# usermod -K type=role root
# usermod -R +root jdoe

This will change the root account to be a role and add the root role to any existing role assignments for the user jdoe.

使用例 13 Set the root account to be a direct login account

Change the root account from being a role to a direct login account.

# rolemod -K type=normal root

This will change the root account to no longer be a role, so direct login to it on the console will be allowed.

使用例 14 Deleting a User

Delete the user and remove their home directory.

# userdel -r jdoe

This will remove the user entry from the passwd, shadow, group and user_attr databases, and will delete the users home directory and all of its content.

終了ステータス

In case of an error, these commands print an error message and exit with one of the following values:

1

行おうとした操作に必要な権限がありません。

2

コマンド構文が無効でした。usermod コマンドの使用法に関するメッセージが表示されます。

3

オプションに無効な引数が指定されました。

4

–u オプションで指定された gid または uid はすでに使用されています。

5

password ファイルと shadow ファイルが互いに整合していません。pwconv(8) がエラーの修正に役立つ可能性があります。passwd(5) および shadow(5) を参照してください。

6

変更されるログインが存在しないか、gid または uid が存在しません。

7

grouppasswd、または shadow ファイルがありません。

9

グループまたはユーザーの名前はすでに使用されています。

10

passwdshadow、または user_attr ファイルを更新できません。

11

ホームディレクトリを移動するための容量が不足しています (–m オプション)。

12

新しいホームディレクトリを作成、削除、または移動できません。

13

要求されたログインはすでに使用されています。

14

予期しない失敗。

16

グループデータベースを更新できません。

17

プロジェクトデータベースを更新できません。

18

承認が不十分です。

19

役割がありません。

20

プロファイルがありません。

21

特権がありません。

22

ラベルがありません。

23

グループがありません。

24

システムで Trusted Extensions が実行されていません。

25

プロジェクトがありません。

26

auto_home を更新できません。

ファイル

/etc/datemsk

/etc/passwd

/etc/shadow

/etc/group

/etc/skel

/usr/include/limits.h

/etc/user_attr

属性

属性についての詳細は、マニュアルページの attributes(7) を参照してください。

属性タイプ
属性値
使用条件
system/core-os
インタフェースの安定性
確実

関連項目

auths(1), passwd(1), profiles(1), roles(1), getdate(3C), auth_attr(5), group(5), passwd(5), prof_attr(5), project(5), shadow(5), user_attr(5), attributes(7), labels(7), rbac(7), groupadd(8), groupdel(8), groupmod(8), grpck(8), logins(8), pwck(8), pwconv(8), roledel(8), userdel(8)

Managing User Accounts and User Environments in Oracle Solaris 11.4

Working With Oracle Solaris 11.4 Directory and Naming Services: LDAP

診断

エラーが発生した場合、useradd はエラーメッセージを表示し、ゼロ以外のステータスで終了します。If the error occurred because LDAP is misconfigured, the error message is preceded by "LDAP configuration problem".

次のメッセージは、指定された login がすでに使用されていることを示します。

UX: useradd: ERROR: login is already in use. Choose another.

次のメッセージは、–u オプションで指定された uid が一意でないことを示します。

UX: useradd: ERROR: uid uid is already in use. Choose another.

次のメッセージは、–g オプションで指定された group がまだ作成されていないことを示します。

UX: useradd: ERROR: group group does not exist. Choose another.

次のメッセージは、–u オプションで指定された uid が予約済み UID の範囲 (0 から 99) に含まれていることを示します。

UX: useradd: WARNING: uid uid is reserved.

The following indicates that the uid specified with the –u option exceeds MAXUID as defined in <sys/param.h>:

UX: useradd: ERROR: uid uid is too big. Choose another.

次のメッセージは、/etc/passwd または /etc/shadow ファイルが存在しないことを示します。

UX: useradd: ERROR: Cannot update system files - login cannot be created.

次のメッセージは、コマンドを実行したユーザーに、この操作を実行するための十分な承認がないことを示します。

UX: useradd: ERROR: Permission denied.

次のメッセージは、useradd コマンドで無効なディレクトリが指定されたことを示します。

UX: invalid_directory is not a valid directory. Choose another.

These utilities add or modify definitions in the passwd, shadow, group, project, and user_attr databases in the scope (default or specified).They will verify the uniqueness of the user name (or role) and user id and the existence of any group names specified against the external name service.