{"id":373,"date":"2019-10-21T20:00:26","date_gmt":"2019-10-21T18:00:26","guid":{"rendered":"http:\/\/linuxboxen2.dk\/?p=373"},"modified":"2019-10-21T20:00:26","modified_gmt":"2019-10-21T18:00:26","slug":"org_useradd","status":"publish","type":"post","link":"https:\/\/www.linuxboxen.dk\/?p=373","title":{"rendered":"USERADD"},"content":{"rendered":"<div class=\"view-content\">\n<div class=\"views-row\">\n<div class=\"views-field views-field-body\">\n<div class=\"field-content\">\n<p>USERADD(8)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System Management Commands\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 USERADD(8)<\/p>\n<p>NAME<\/p>\n<p>useradd &#8211; create a new user or update default new user information<\/p>\n<p>SYNOPSIS<\/p>\n<p>useradd [options] LOGIN<\/p>\n<p>useradd -D<\/p>\n<p>useradd -D [options]<\/p>\n<p>DESCRIPTION<\/p>\n<p>When invoked without the -D option, the useradd command creates a new<br \/>\nuser account using the values specified on the command line plus the<br \/>\ndefault values from the system. Depending on command line options,<br \/>\nthe useradd command will update system files and may also create the<br \/>\nnew user&#8217;s home directory and copy initial files.<\/p>\n<p>By default, a group will also be created for the new user (see -g,<br \/>\n-N, -U, and USERGROUPS_ENAB).<\/p>\n<p>OPTIONS<\/p>\n<p>The options which apply to the useradd command are:<\/p>\n<p>-b, &#8211;base-dir BASE_DIR<br \/>\nThe default base directory for the system if -dHOME_DIR is not<br \/>\nspecified.\u00a0 BASE_DIR is concatenated with the account name to<br \/>\ndefine the home directory. If the -m option is not used, BASE_DIR<br \/>\nmust exist.<\/p>\n<p>If this option is not specified, useradd will use the base<br \/>\ndirectory specified by the HOME variable in \/etc\/default\/useradd,<br \/>\nor \/home by default.<\/p>\n<p>-c, &#8211;comment COMMENT<br \/>\nAny text string. It is generally a short description of the<br \/>\nlogin, and is currently used as the field for the user&#8217;s full<br \/>\nname.<\/p>\n<p>-d, &#8211;home HOME_DIR<br \/>\nThe new user will be created using HOME_DIR as the value for the<br \/>\nuser&#8217;s login directory. The default is to append the LOGIN name<br \/>\nto BASE_DIR and use that as the login directory name. The<br \/>\ndirectory HOME_DIR does not have to exist but will not be created<br \/>\nif it is missing.<\/p>\n<p>-D, &#8211;defaults<br \/>\nSee below, the subsection &#8220;Changing the default values&#8221;.<\/p>\n<p>-e, &#8211;expiredate EXPIRE_DATE<br \/>\nThe date on which the user account will be disabled. The date is<br \/>\nspecified in the format YYYY-MM-DD.<\/p>\n<p>If not specified, useradd will use the default expiry date<br \/>\nspecified by the EXPIRE variable in \/etc\/default\/useradd, or an<br \/>\nempty string (no expiry) by default.<\/p>\n<p>-f, &#8211;inactive INACTIVE<br \/>\nThe number of days after a password expires until the account is<br \/>\npermanently disabled. A value of 0 disables the account as soon<br \/>\nas the password has expired, and a value of -1 disables the<br \/>\nfeature.<\/p>\n<p>If not specified, useradd will use the default inactivity period<br \/>\nspecified by the INACTIVE variable in \/etc\/default\/useradd, or -1<br \/>\nby default.<\/p>\n<p>-g, &#8211;gid GROUP<br \/>\nThe group name or number of the user&#8217;s initial login group. The<br \/>\ngroup name must exist. A group number must refer to an already<br \/>\nexisting group.<\/p>\n<p>If not specified, the behavior of useradd will depend on the<br \/>\nUSERGROUPS_ENAB variable in \/etc\/login.defs. If this variable is<br \/>\nset to yes (or -U\/&#8211;user-group is specified on the command line),<br \/>\na group will be created for the user, with the same name as her<br \/>\nloginname. If the variable is set to no (or -N\/&#8211;no-user-group is<br \/>\nspecified on the command line), useradd will set the primary<br \/>\ngroup of the new user to the value specified by the GROUP<br \/>\nvariable in \/etc\/default\/useradd, or 100 by default.<\/p>\n<p>-G, &#8211;groups GROUP1[,GROUP2,&#8230;[,GROUPN]]]<br \/>\nA list of supplementary groups which the user is also a member<br \/>\nof. Each group is separated from the next by a comma, with no<br \/>\nintervening whitespace. The groups are subject to the same<br \/>\nrestrictions as the group given with the -g option. The default<br \/>\nis for the user to belong only to the initial group.<\/p>\n<p>-h, &#8211;help<br \/>\nDisplay help message and exit.<\/p>\n<p>-k, &#8211;skel SKEL_DIR<br \/>\nThe skeleton directory, which contains files and directories to<br \/>\nbe copied in the user&#8217;s home directory, when the home directory<br \/>\nis created by useradd.<\/p>\n<p>This option is only valid if the -m (or &#8211;create-home) option is<br \/>\nspecified.<\/p>\n<p>If this option is not set, the skeleton directory is defined by<br \/>\nthe SKEL variable in \/etc\/default\/useradd or, by default,<br \/>\n\/etc\/skel.<\/p>\n<p>If possible, the ACLs and extended attributes are copied.<\/p>\n<p>-K, &#8211;key KEY=VALUE<br \/>\nOverrides \/etc\/login.defs defaults (UID_MIN, UID_MAX, UMASK,<br \/>\nPASS_MAX_DAYS and others).<\/p>\n<p>Example: -K PASS_MAX_DAYS=-1 can be used when creating system<br \/>\naccount to turn off password ageing, even though system account<br \/>\nhas no password at all. Multiple -K options can be specified,<br \/>\ne.g.: -K UID_MIN=100-K UID_MAX=499<\/p>\n<p>-l, &#8211;no-log-init<br \/>\nDo not add the user to the lastlog and faillog databases.<\/p>\n<p>By default, the user&#8217;s entries in the lastlog and faillog<br \/>\ndatabases are resetted to avoid reusing the entry from a<br \/>\npreviously deleted user.<\/p>\n<p>-m, &#8211;create-home<br \/>\nCreate the user&#8217;s home directory if it does not exist. The files<br \/>\nand directories contained in the skeleton directory (which can be<br \/>\ndefined with the -k option) will be copied to the home directory.<\/p>\n<p>By default, if this option is not specified and CREATE_HOME is<br \/>\nnot enabled, no home directories are created.<\/p>\n<p>-M<br \/>\nDo no create the user&#8217;s home directory, even if the system wide<br \/>\nsetting from \/etc\/login.defs (CREATE_HOME) is set to yes.<\/p>\n<p>-N, &#8211;no-user-group<br \/>\nDo not create a group with the same name as the user, but add the<br \/>\nuser to the group specified by the -g option or by the GROUP<br \/>\nvariable in \/etc\/default\/useradd.<\/p>\n<p>The default behavior (if the -g, -N, and -U options are not<br \/>\nspecified) is defined by the USERGROUPS_ENAB variable in<br \/>\n\/etc\/login.defs.<\/p>\n<p>-o, &#8211;non-unique<br \/>\nAllow the creation of a user account with a duplicate<br \/>\n(non-unique) UID.<\/p>\n<p>This option is only valid in combination with the -u option.<\/p>\n<p>-p, &#8211;password PASSWORD<br \/>\nThe encrypted password, as returned by crypt(3). The default is<br \/>\nto disable the password.<\/p>\n<p>Note: This option is not recommended because the password (or<br \/>\nencrypted password) will be visible by users listing the<br \/>\nprocesses.<\/p>\n<p>You should make sure the password respects the system&#8217;s password<br \/>\npolicy.<\/p>\n<p>-r, &#8211;system<br \/>\nCreate a system account.<\/p>\n<p>System users will be created with no aging information in<br \/>\n\/etc\/shadow, and their numeric identifiers are chosen in the<br \/>\nSYS_UID_MIN-SYS_UID_MAX range, defined in \/etc\/login.defs,<br \/>\ninstead of UID_MIN-UID_MAX (and their GID counterparts for the<br \/>\ncreation of groups).<\/p>\n<p>Note that useradd will not create a home directory for such an<br \/>\nuser, regardless of the default setting in \/etc\/login.defs<br \/>\n(CREATE_HOME). You have to specify the -m options if you want a<br \/>\nhome directory for a system account to be created.<\/p>\n<p>-R, &#8211;root CHROOT_DIR<br \/>\nApply changes in the CHROOT_DIR directory and use the<br \/>\nconfiguration files from the CHROOT_DIR directory.<\/p>\n<p>-s, &#8211;shell SHELL<br \/>\nThe name of the user&#8217;s login shell. The default is to leave this<br \/>\nfield blank, which causes the system to select the default login<br \/>\nshell specified by the SHELL variable in \/etc\/default\/useradd, or<br \/>\nan empty string by default.<\/p>\n<p>-u, &#8211;uid UID<br \/>\nThe numerical value of the user&#8217;s ID. This value must be unique,<br \/>\nunless the -o option is used. The value must be non-negative. The<br \/>\ndefault is to use the smallest ID value greater than or equal to<br \/>\nUID_MIN and greater than every other user.<\/p>\n<p>See also the -r option and the UID_MAX description.<\/p>\n<p>-U, &#8211;user-group<br \/>\nCreate a group with the same name as the user, and add the user<br \/>\nto this group.<\/p>\n<p>The default behavior (if the -g, -N, and -U options are not<br \/>\nspecified) is defined by the USERGROUPS_ENAB variable in<br \/>\n\/etc\/login.defs.<\/p>\n<p>-Z, &#8211;selinux-user SEUSER<br \/>\nThe SELinux user for the user&#8217;s login. The default is to leave<br \/>\nthis field blank, which causes the system to select the default<br \/>\nSELinux user.<\/p>\n<p>Changing the default values<br \/>\nWhen invoked with only the -D option, useradd will display the<br \/>\ncurrent default values. When invoked with -D plus other options,<br \/>\nuseradd will update the default values for the specified options.<br \/>\nValid default-changing options are:<\/p>\n<p>-b, &#8211;base-dir BASE_DIR<br \/>\nThe path prefix for a new user&#8217;s home directory. The user&#8217;s name<br \/>\nwill be affixed to the end of BASE_DIR to form the new user&#8217;s<br \/>\nhome directory name, if the -d option is not used when creating a<br \/>\nnew account.<\/p>\n<p>This option sets the HOME variable in \/etc\/default\/useradd.<\/p>\n<p>-e, &#8211;expiredate EXPIRE_DATE<br \/>\nThe date on which the user account is disabled.<\/p>\n<p>This option sets the EXPIRE variable in \/etc\/default\/useradd.<\/p>\n<p>-f, &#8211;inactive INACTIVE<br \/>\nThe number of days after a password has expired before the<br \/>\naccount will be disabled.<\/p>\n<p>This option sets the INACTIVE variable in \/etc\/default\/useradd.<\/p>\n<p>-g, &#8211;gid GROUP<br \/>\nThe group name or ID for a new user&#8217;s initial group (when the<br \/>\n-N\/&#8211;no-user-group is used or when the USERGROUPS_ENAB variable<br \/>\nis set to no in \/etc\/login.defs). The named group must exist, and<br \/>\na numerical group ID must have an existing entry.<\/p>\n<p>This option sets the GROUP variable in \/etc\/default\/useradd.<\/p>\n<p>-s, &#8211;shell SHELL<br \/>\nThe name of a new user&#8217;s login shell.<\/p>\n<p>This option sets the SHELL variable in \/etc\/default\/useradd.<\/p>\n<p>NOTES<\/p>\n<p>The system administrator is responsible for placing the default user<br \/>\nfiles in the \/etc\/skel\/ directory (or any other skeleton directory<br \/>\nspecified in \/etc\/default\/useradd or on the command line).<\/p>\n<p>CAVEATS<\/p>\n<p>You may not add a user to a NIS or LDAP group. This must be performed<br \/>\non the corresponding server.<\/p>\n<p>Similarly, if the username already exists in an external user<br \/>\ndatabase such as NIS or LDAP, useradd will deny the user account<br \/>\ncreation request.<\/p>\n<p>Usernames must start with a lower case letter or an underscore,<br \/>\nfollowed by lower case letters, digits, underscores, or dashes. They<br \/>\ncan end with a dollar sign. In regular expression terms:<br \/>\n[a-z_][a-z0-9_-]*[$]?<\/p>\n<p>Usernames may only be up to 32 characters long.<\/p>\n<p>CONFIGURATION<\/p>\n<p>The following configuration variables in \/etc\/login.defs change the<br \/>\nbehavior of this tool:<\/p>\n<p>CREATE_HOME (boolean)<br \/>\nIndicate if a home directory should be created by default for new<br \/>\nusers.<\/p>\n<p>This setting does not apply to system users, and can be<br \/>\noverridden on the command line.<\/p>\n<p>GID_MAX (number), GID_MIN (number)<br \/>\nRange of group IDs used for the creation of regular groups by<br \/>\nuseradd, groupadd, or newusers.<\/p>\n<p>The default value for GID_MIN (resp.\u00a0 GID_MAX) is 1000 (resp.<br \/>\n60000).<\/p>\n<p>MAIL_DIR (string)<br \/>\nThe mail spool directory. This is needed to manipulate the<br \/>\nmailbox when its corresponding user account is modified or<br \/>\ndeleted. If not specified, a compile-time default is used.<\/p>\n<p>MAIL_FILE (string)<br \/>\nDefines the location of the users mail spool files relatively to<br \/>\ntheir home directory.<\/p>\n<p>The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod,<br \/>\nand userdel to create, move, or delete the user&#8217;s mail spool.<\/p>\n<p>If MAIL_CHECK_ENAB is set to yes, they are also used to define the<br \/>\nMAIL environment variable.<\/p>\n<p>MAX_MEMBERS_PER_GROUP (number)<br \/>\nMaximum members per group entry. When the maximum is reached, a<br \/>\nnew group entry (line) is started in \/etc\/group (with the same<br \/>\nname, same password, and same GID).<\/p>\n<p>The default value is 0, meaning that there are no limits in the<br \/>\nnumber of members in a group.<\/p>\n<p>This feature (split group) permits to limit the length of lines<br \/>\nin the group file. This is useful to make sure that lines for NIS<br \/>\ngroups are not larger than 1024 characters.<\/p>\n<p>If you need to enforce such limit, you can use 25.<\/p>\n<p>Note: split groups may not be supported by all tools (even in the<br \/>\nShadow toolsuite). You should not use this variable unless you<br \/>\nreally need it.<\/p>\n<p>PASS_MAX_DAYS (number)<br \/>\nThe maximum number of days a password may be used. If the<br \/>\npassword is older than this, a password change will be forced. If<br \/>\nnot specified, -1 will be assumed (which disables the<br \/>\nrestriction).<\/p>\n<p>PASS_MIN_DAYS (number)<br \/>\nThe minimum number of days allowed between password changes. Any<br \/>\npassword changes attempted sooner than this will be rejected. If<br \/>\nnot specified, -1 will be assumed (which disables the<br \/>\nrestriction).<\/p>\n<p>PASS_WARN_AGE (number)<br \/>\nThe number of days warning given before a password expires. A<br \/>\nzero means warning is given only upon the day of expiration, a<br \/>\nnegative value means no warning is given. If not specified, no<br \/>\nwarning will be provided.<\/p>\n<p>SYS_GID_MAX (number), SYS_GID_MIN (number)<br \/>\nRange of group IDs used for the creation of system groups by<br \/>\nuseradd, groupadd, or newusers.<\/p>\n<p>The default value for SYS_GID_MIN (resp.\u00a0 SYS_GID_MAX) is 101<br \/>\n(resp.\u00a0 GID_MIN-1).<\/p>\n<p>SYS_UID_MAX (number), SYS_UID_MIN (number)<br \/>\nRange of user IDs used for the creation of system users by<br \/>\nuseradd or newusers.<\/p>\n<p>The default value for SYS_UID_MIN (resp.\u00a0 SYS_UID_MAX) is 101<br \/>\n(resp.\u00a0 UID_MIN-1).<\/p>\n<p>UID_MAX (number), UID_MIN (number)<br \/>\nRange of user IDs used for the creation of regular users by<br \/>\nuseradd or newusers.<\/p>\n<p>The default value for UID_MIN (resp.\u00a0 UID_MAX) is 1000 (resp.<br \/>\n60000).<\/p>\n<p>UMASK (number)<br \/>\nThe file mode creation mask is initialized to this value. If not<br \/>\nspecified, the mask will be initialized to 022.<\/p>\n<p>useradd and newusers use this mask to set the mode of the home<br \/>\ndirectory they create<\/p>\n<p>It is also used by login to define users&#8217; initial umask. Note<br \/>\nthat this mask can be overridden by the user&#8217;s GECOS line (if<br \/>\nQUOTAS_ENAB is set) or by the specification of a limit with the K<br \/>\nidentifier in limits(5).<\/p>\n<p>USERGROUPS_ENAB (boolean)<br \/>\nEnable setting of the umask group bits to be the same as owner<br \/>\nbits (examples: 022 -&gt; 002, 077 -&gt; 007) for non-root users, if<br \/>\nthe uid is the same as gid, and username is the same as the<br \/>\nprimary group name.<\/p>\n<p>If set to yes, userdel will remove the user&#8217;s group if it<br \/>\ncontains no more members, and useradd will create by default a<br \/>\ngroup with the name of the user.<\/p>\n<p>FILES<\/p>\n<p>\/etc\/passwd<br \/>\nUser account information.<\/p>\n<p>\/etc\/shadow<br \/>\nSecure user account information.<\/p>\n<p>\/etc\/group<br \/>\nGroup account information.<\/p>\n<p>\/etc\/gshadow<br \/>\nSecure group account information.<\/p>\n<p>\/etc\/default\/useradd<br \/>\nDefault values for account creation.<\/p>\n<p>\/etc\/skel\/<br \/>\nDirectory containing default files.<\/p>\n<p>\/etc\/login.defs<br \/>\nShadow password suite configuration.<\/p>\n<p>EXIT VALUES<\/p>\n<p>The useradd command exits with the following values:<\/p>\n<p>0<br \/>\nsuccess<\/p>\n<p>1<br \/>\ncan&#8217;t update password file<\/p>\n<p>2<br \/>\ninvalid command syntax<\/p>\n<p>3<br \/>\ninvalid argument to option<\/p>\n<p>4<br \/>\nUID already in use (and no -o)<\/p>\n<p>6<br \/>\nspecified group doesn&#8217;t exist<\/p>\n<p>9<br \/>\nusername already in use<\/p>\n<p>10<br \/>\ncan&#8217;t update group file<\/p>\n<p>12<br \/>\ncan&#8217;t create home directory<\/p>\n<p>14<br \/>\ncan&#8217;t update SELinux user mapping<\/p>\n<p>SEE ALSO<\/p>\n<p>chfn(1), chsh(1), passwd(1), crypt(3), groupadd(8), groupdel(8),<br \/>\ngroupmod(8), login.defs(5), newusers(8), userdel(8), usermod(8).<\/p>\n<p>COLOPHON<\/p>\n<p>This page is part of the shadow-utils (utilities for managing<br \/>\naccounts and shadow password files) project.\u00a0 Information about the<br \/>\nproject can be found at \u27e8http:\/\/pkg-shadow.alioth.debian.org\/\u27e9.\u00a0 If<br \/>\nyou have a bug report for this manual page, see<br \/>\n\u27e8http:\/\/pkg-shadow.alioth.debian.org\/getinvolved.php\u27e9.\u00a0 This page was<br \/>\nobtained from the project&#8217;s upstream Subversion repository<br \/>\n(svn:\/\/anonscm.debian.org\/pkg-shadow\/) on 2014-12-30.\u00a0 If you dis\u2010<br \/>\ncover any rendering problems in this HTML version of the page, or you<br \/>\nbelieve there is a better or more up-to-date source for the page, or<br \/>\nyou have corrections or improvements to the information in this<br \/>\nCOLOPHON (which is not part of the original manual page), send a mail<br \/>\nto\u00a0man-pages@man7.org<\/p>\n<p>shadow-utils 4.1.5.1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 01\/27\/2014\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 USERADD(8)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"view-footer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>USERADD(8)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System Management Commands\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 USERADD(8) NAME useradd &#8211; create a new user or update default new user information SYNOPSIS useradd [options] LOGIN useradd -D useradd -D [options] DESCRIPTION When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line plus the default values from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[8],"tags":[],"class_list":["post-373","post","type-post","status-publish","format-standard","hentry","category-shell"],"a3_pvc":{"activated":false,"total_views":0,"today_views":0},"_links":{"self":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxboxen.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}