GROUPADD

åç§°
大纲
æè¿°
é项
éç½®æä»¶
æä»¶
CAVEATS
éåºå¼
åè§


åç§°

groupadd − å建ä¸ä¸ªæ°ç»

大纲

groupadd [é项] group

æè¿°

The groupadd command creates a new group account using the values specified on the command line plus the default values from the system. The new group will be entered into the system files as needed.

é项

groupadd å½ä»¤å¯ä»¥æ¥åçé项æï¼

−f, −−force

This option causes the command to simply exit with success status if the specified group already exists. When used with −g, and the specified GID already exists, another (unique) GID is chosen (i.e. −g is turned off).

−g, −−gid GID

The numerical value of the group’s ID. This value must be unique, unless the −o option is used. The value must be non−negative. The default is to use the smallest ID value greater than or equal to GID_MIN and greater than every other group.

See also the −r option and the GID_MAX description.

−h, −−help

ç°å®å¸®å©ä¿¡æ¯å¹¶éåºã

−K, −−key KEY=VALUE

Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and others). Multiple −K options can be specified.

示ä¾ï¼−K GID_MIN=100 −K GID_MAX=499

注æï¼−K GID_MIN=10,GID_MAX=499 å°ä¸è½å·¥ä½ã

−o, −−non−unique

æ¤é项å许添å ä¸ä¸ªä½¿ç¨éå¯ä¸ GID çç»ã

−p, −−password PASSWORD

å å¯äºçå¯ç ï¼å°±å crypt(3) çè¿åå¼ãé»è®¤ä¸ºç¦ç¨å¯ç ã

注æï¼ä¸æ¨è使ç¨è¿ä¸ªé项ï¼å ä¸ºå¯ç (æå å¯è¿çå¯ç )ä¼è¢«ç¨æ·éè¿ååºè¿ä¸ªè¿ç¨èçå°ã

æ¨åºè¯¥ç¡®ä¿å¯ç ç¬¦åç³»ç»çå¯ç æ¿çã

−r, −−system

å建ä¸ä¸ªç³»ç»ç»ã

The numeric identifiers of new system groups are chosen in the SYS_GID_MINSYS_GID_MAX range, defined in login.defs, instead of GID_MINGID_MAX.

−R, −−root CHROOT_DIR

Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

−P, −−prefix PREFIX_DIR

Apply changes in the PREFIX_DIR directory and use the configuration files from the PREFIX_DIR directory. This option does not chroot and is intended for preparing a cross−compilation target. Some limitations: NIS and LDAP users/groups are not verified. PAM authentication is using the host files. No SELINUX support.

éç½®æä»¶

å¨ /etc/login.defs 䏿å¦ä¸éç½®åéï¼å¯ä»¥ç¨æ¥æ´æ¹æ¤å·¥å·çè¡ä¸ºï¼

GID_MAX (number), GID_MIN (number)

useraddï¼groupadd æ newusers å建ç常è§ç»çç» ID çèå´ã

GID_MIN å GID_MAX çé»è®¤å¼å嫿¯ 1000 å 60000ã

MAX_MEMBERS_PER_GROUP (number)

æ¯ä¸ªç»æ¡ç®çæå¤§æåæ°ãè¾¾å°æå¤§å¼æ¶ï¼å¨ /etc/group å¼å§ä¸ä¸ªæ°æ¡ç®(è¡)(使ç¨åæ ·çåç§°ï¼åæ ·çå¯ç ï¼åæ ·ç GID)ã

é»è®¤å¼æ¯ 0ï¼æå³çç»ä¸çæåæ°æ²¡æéå¶ã

æ¤åè½(åå²ç»)å许éå¶ç»æä»¶ä¸çè¡é¿åº¦ãè¿å¯¹äºç¡®ä¿ NIS ç»çè¡æ¯é¿äº 1024 å符ã

妿è¦å¼ºå¶è¿ä¸ªéå¶ï¼å¯ä»¥ä½¿ç¨ 25ã

注æï¼åå²ç»å¯è½ä¸åææå·¥å·çæ¯æ(çè³å¨ Shadow å·¥å·éä¸- )ãæ¨ä¸åºè¯¥ä½¿ç¨è¿ä¸ªåéï¼é¤éççéè¦ã

SYS_GID_MAX (number), SYS_GID_MIN (number)

useraddãgroupadd æ newusers å建çç³»ç»ç»çç» ID çèå´ã

SYS_GID_MIN å SYS_GID_MAX çé»è®¤å¼å嫿¯ 101 å GID_MIN−1ã

æä»¶

/etc/group

ç»è´¦æ·ä¿¡æ¯ã

/etc/gshadow

å®å¨ç»è´¦æ·ä¿¡æ¯ã

/etc/login.defs

Shadow å¯ç å¥ä»¶éç½®ã

CAVEATS

ç»åå¿é¡»ä»¥å°å忝æèä¸å线å¼å¤´ï¼è·éå°å忝ãä¸å线æç- 横线ãå¯ä»¥ç±ç¾å符å·ç»æãç¨æ£å表达å¼å°±æ¯ï¼[a−z_][a−z0−9_−]*[$]?

ç»åæé¿ä¸º 16 个å符ã

You may not add a NIS or LDAP group. This must be performed on the corresponding server.

If the groupname already exists in an external group database such as NIS or LDAP, groupadd will deny the group creation request.

éåºå¼

groupadd å¯è½ä»¥å¦ä¸å¼éåºï¼

0

æå

2

æ æçå½ä»¤è¯æ³

3

ç»äºé项ä¸ä¸ªæ æçåæ°

4

GID ä¸å¯ä¸ (没æä½¿ç¨ −o)

9

ç»åä¸å¯ä¸

10

æ æ³æ´æ°ç»æä»¶

åè§

chfn(1), chsh(1), passwd(1), gpasswd(8), groupdel(8), groupmod(8), login.defs(5), useradd(8), userdel(8), usermod(8).