1*25a24f0bSjsg.\" $OpenBSD: adduser.8,v 1.48 2022/02/18 23:17:16 jsg Exp $ 2cdbdb68aSaaron.\" 394a17dd4Sdownsj.\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 494a17dd4Sdownsj.\" All rights reserved. 594a17dd4Sdownsj.\" 694a17dd4Sdownsj.\" Redistribution and use in source and binary forms, with or without 794a17dd4Sdownsj.\" modification, are permitted provided that the following conditions 894a17dd4Sdownsj.\" are met: 994a17dd4Sdownsj.\" 1. Redistributions of source code must retain the above copyright 1094a17dd4Sdownsj.\" notice, this list of conditions and the following disclaimer. 1194a17dd4Sdownsj.\" 2. Redistributions in binary form must reproduce the above copyright 1294a17dd4Sdownsj.\" notice, this list of conditions and the following disclaimer in the 1394a17dd4Sdownsj.\" documentation and/or other materials provided with the distribution. 1494a17dd4Sdownsj.\" 1594a17dd4Sdownsj.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1694a17dd4Sdownsj.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1794a17dd4Sdownsj.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1894a17dd4Sdownsj.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1994a17dd4Sdownsj.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2094a17dd4Sdownsj.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2194a17dd4Sdownsj.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2294a17dd4Sdownsj.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2394a17dd4Sdownsj.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2494a17dd4Sdownsj.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2594a17dd4Sdownsj.\" SUCH DAMAGE. 2694a17dd4Sdownsj.\" 2794a17dd4Sdownsj.\" $From: adduser.8,v 1.12 1996/08/28 17:54:13 adam Exp $ 28*25a24f0bSjsg.Dd $Mdocdate: February 18 2022 $ 2994a17dd4Sdownsj.Dt ADDUSER 8 30fc8533a3Saaron.Os 3194a17dd4Sdownsj.Sh NAME 325a3a102aSaaron.Nm adduser , 335a3a102aSaaron.Nm rmuser 345a3a102aSaaron.Nd add and delete users from the system 3594a17dd4Sdownsj.Sh SYNOPSIS 3694a17dd4Sdownsj.Nm adduser 37e69a7a03Sjmc.Bk -words 3828045b73Saaron.Oo Fl batch Ar username 3928045b73Saaron.Oo Ar group Ns Op , Ns Ar group 4028045b73Saaron.Ar ... 4128045b73Saaron.Oc 4228045b73Saaron.Op Ar fullname 4328045b73Saaron.Op Ar password 4428045b73Saaron.Oc 456f10db5aSaaron.Op Fl check_only 46fa4eb53aSmillert.Op Fl class Ar login_class 476f10db5aSaaron.Op Fl config_create 485a3a102aSaaron.Op Fl dotdir Ar directory 495a3a102aSaaron.Oo 505a3a102aSaaron.Fl e 51f7a0a450Sjmc.Ar method | Fl encryption Ar method 525a3a102aSaaron.Oc 536f10db5aSaaron.Op Fl group Ar login_group 54f7a0a450Sjmc.Op Fl h | help | \&? 555a3a102aSaaron.Op Fl home Ar partition 565a3a102aSaaron.Op Fl message Ar file 576f10db5aSaaron.Op Fl noconfig 586f10db5aSaaron.Op Fl shell Ar shell 596f10db5aSaaron.Op Fl s | silent | q | quiet 605a3a102aSaaron.Op Fl uid_start Ar uid 615a3a102aSaaron.Op Fl uid_end Ar uid 626f10db5aSaaron.Op Fl v | verbose 6384079b4aSderaadt.Op Fl unencrypted 64e69a7a03Sjmc.Ek 655a3a102aSaaron.Pp 669d0b46bcSjmc.Nm rmuser 679d0b46bcSjmc.Op Ar username 6894a17dd4Sdownsj.Sh DESCRIPTION 695a3a102aSaaronThe 705a3a102aSaaron.Nm adduser 71cdbdb68aSaaronprogram adds new users to the system. 72cdbdb68aSaaronThe 735a3a102aSaaron.Nm rmuser 74cdbdb68aSaaronprogram removes users from the system. 75cdbdb68aSaaronWhen not passed any arguments, both 765a3a102aSaaronutilities operate in interactive mode and prompt for any required information. 775a3a102aSaaron.Pp 7838a123d1SaaronThe options are as follows: 7938a123d1Saaron.Bl -tag -width Ds 8038a123d1Saaron.It Xo Fl batch Ar username 8138a123d1Saaron.Oo Ar group Ns Op , Ns Ar group 8238a123d1Saaron.Ar ... Oc 8338a123d1Saaron.Op Ar fullname 8438a123d1Saaron.Op Ar password 8538a123d1Saaron.Xc 865d1428ebSjmcEnter batch mode in which multiple users are specified on the command line 8738a123d1Saaronin a compact format. 8838a123d1SaaronBy default the password is assumed to already be properly encrypted. 8938a123d1Saaron.It Fl check_only 9038a123d1SaaronCheck the passwd, group, and shells databases for consistency and problems 9138a123d1Saaronthen exit without performing any other operation. 92fa4eb53aSmillert.It Fl class Ar login_class 93fa4eb53aSmillertUse the specified 94fa4eb53aSmillert.Ar login_class 95d7bb54ecSmillertas the default user login class. 96fa4eb53aSmillertSee 97fa4eb53aSmillert.Xr login.conf 5 98fa4eb53aSmillertfor further details. 9938a123d1Saaron.It Fl config_create 10038a123d1SaaronCreate or edit default configuration information and message file before 10138a123d1Saaronproceeding with the normal interactive adduser procedure. 10238a123d1Saaron.It Fl dotdir Ar directory 10338a123d1SaaronCopy files from 10438a123d1Saaron.Ar directory 10538a123d1Saaroninto the HOME directory of new users. 10638a123d1SaaronFiles named in the fashion of 10738a123d1Saaron.Dq Pa dot.foo 10838a123d1Saaronwill be renamed to 10938a123d1Saaron.Dq Pa .foo . 11038a123d1SaaronBy default, all files are made writable and readable by 11138a123d1Saarontheir owner. 11238a123d1Saaron.\" don't allow group or world to write files and allow only owner 11338a123d1Saaron.\" to read/execute/write .rhost, .Xauthority, .kermrc, .netrc, Mail, 11438a123d1Saaron.\" prv, iscreen, term. 115d741230eSjmc.It Fl encryption , e Ar method 11638a123d1SaaronEncrypt local passwords using 11738a123d1Saaron.Ar method 11838a123d1Saaronof encryption as described in 119d0159827Smillert.Xr login.conf 5 . 120d7bb54ecSmillertIf 121d7bb54ecSmillert.Ar method 122d7bb54ecSmillertis 123d7bb54ecSmillert.Dq auto , 124d7bb54ecSmillertthe encryption type will be derived from the user's login class. 12538a123d1Saaron.It Fl group Ar login_group 12638a123d1SaaronSpecify the default login group. 12738a123d1SaaronA value of 12838a123d1Saaron.Ar USER 12938a123d1Saaronmeans that the username is to be used as the login group. 130f7a0a450Sjmc.It Fl help , h , \&? 13138a123d1SaaronPrint a summary of options and exit. 13238a123d1Saaron.It Fl home Ar partition 13338a123d1SaaronSpecify the default home partition where all users' home directories 13438a123d1Saaronare to be located. 13538a123d1Saaron.It Fl message Ar file 13638a123d1SaaronSend new users a welcome message from 13738a123d1Saaron.Ar file . 13838a123d1SaaronSpecifying a value of 13938a123d1Saaron.Dq no 14038a123d1Saaronfor 14138a123d1Saaron.Ar file 14238a123d1Saaroncauses no message to be sent to new users. 14338a123d1Saaron.It Fl noconfig 14438a123d1SaaronDo not read the default configuration file. 14538a123d1Saaron.It Fl shell Ar shell 14638a123d1SaaronSpecify the default shell for new users. 14738a123d1Saaron.It Xo 148d741230eSjmc.Fl silent , s , 149d741230eSjmc.Fl quiet , q 15038a123d1Saaron.Xc 15138a123d1SaaronCauses the program to print fewer warnings, questions, and bug reports. 1524424054eSmillert.It Fl uid_start Ar uid 15338a123d1SaaronUse UIDs from 15438a123d1Saaron.Ar uid 15538a123d1Saaronup when automatically generating UIDs. 1564424054eSmillert.It Fl uid_end Ar uid 1574424054eSmillertDo not use UIDs higher than 1584424054eSmillert.Ar uid 1594424054eSmillertwhen generating UIDs. 16038a123d1Saaron.It Fl unencrypted 16138a123d1SaaronCauses the program to assume that the password given in batch mode is 16238a123d1Saaronunencrypted. 163fa152b29StomThe password will be encrypted before being added to the password file. 164fa152b29StomUse of this option is discouraged, as the username and cleartext password 165fa152b29Stomwill appear in the process list, which is visible to users. 166d741230eSjmc.It Fl verbose , v 16738a123d1SaaronCauses the program to print many warnings and questions. 16838a123d1SaaronThis option is recommended for novice users. 16938a123d1Saaron.El 17038a123d1Saaron.Pp 1715a3a102aSaaron.Nm adduser 1725a3a102aSaaronfirst performs consistency checks on the password, group, and shell databases. 1735a3a102aSaaronThis includes finding any duplicate user or group names, illegal shells, or 174cdbdb68aSaaronshells that aren't executable. 175cdbdb68aSaaronOnce these tests are passed, 1766931a8aaSaaron.Nm 1775a3a102aSaaronperforms the following operations for each new user: 1785a3a102aSaaron.Bl -enum -offset indent 1795a3a102aSaaron.It 1805a3a102aSaaronAdd the appropriate entries to the password and group files and re-generate 1815a3a102aSaaronthe password database using 1825a3a102aSaaron.Xr pwd_mkdb 8 . 1835a3a102aSaaron.It 1842567d56aSmillertCreate a home directory and copy all files from the skeletal 1852567d56aSmillertlogin directory (normally 186b22285deSmillert.Pa /etc/skel ) 1875a3a102aSaaronto this new directory. 1882567d56aSmillertFiles named in the fashion of 1892567d56aSmillert.Dq Pa dot.foo 1902567d56aSmillertwill be renamed to 1912567d56aSmillert.Dq Pa .foo 192e69a7a03Sjmcin the new directory. 1935a3a102aSaaron.It 1945a3a102aSaaronMails the new user a welcome message at the discretion of the account creator. 1955a3a102aSaaron.El 1965a3a102aSaaron.Pp 1975a3a102aSaaronSimilarly, when removing a user, 1985a3a102aSaaron.Nm rmuser 1995a3a102aSaaronperforms the following operations for the given 2005a3a102aSaaron.Ar username : 2015a3a102aSaaron.Bl -enum -offset indent 2025a3a102aSaaron.It 2035a3a102aSaaronRemoves any 2045a3a102aSaaron.Xr crontab 1 2055a3a102aSaaronentries or 2065a3a102aSaaron.Xr at 1 2075a3a102aSaaronjobs belonging to the user. 2085a3a102aSaaron.It 2095a3a102aSaaronRemoves the user from the password database and all groups in the group 210cdbdb68aSaarondatabase. 211cdbdb68aSaaronIf a group becomes empty and its name is the same as the username, 2125a3a102aSaaronthe group is removed (this complements 213d741230eSjmc.Nm adduser Ns 's 2145a3a102aSaaronunique per-user groups). 2155a3a102aSaaron.It 2165a3a102aSaaronRecursively deletes all files in the user's home directory and removes the 2175a3a102aSaarondirectory itself (provided the directory actually belongs to the user). 2185a3a102aSaaron.Nm rmuser 2195a3a102aSaaronprompts for confirmation before actually doing this. 2205a3a102aSaaron.It 2215a3a102aSaaronRemoves the user's incoming mail file if one exists. 2225a3a102aSaaron.El 2235a3a102aSaaron.Pp 2245a3a102aSaaronUnderstandably, 2255a3a102aSaaron.Nm rmuser 2265a3a102aSaaronpolitely refuses to remove users whose UID is 0 (typically root). 22794a17dd4Sdownsj.Sh RESTRICTIONS 2286f10db5aSaaron.Bl -tag -width Ds 22994a17dd4Sdownsj.It Sy username 2306b22066cSmillertIt is recommended that login names contain only lowercase characters 2319d0b46bcSjmcand digits. 2329d0b46bcSjmcThey may also contain uppercase characters, non-leading hyphens, 233f4590bb1Sjmcperiods, underscores, and a trailing 234f4590bb1Sjmc.Ql $ . 235f4590bb1SjmcLogin names may not be longer than 31 characters. 23694a17dd4Sdownsj.\" The reasons for this limit are "Historical". 23794a17dd4Sdownsj.\" Given that people have traditionally wanted to break this 23894a17dd4Sdownsj.\" limit for aesthetic reasons, it's never been of great importance to break 23994a17dd4Sdownsj.\" such a basic fundamental parameter in UNIX. 24094a17dd4Sdownsj.\" You can change UT_NAMESIZE in /usr/include/utmp.h and recompile the 24194a17dd4Sdownsj.\" world; people have done this and it works, but you will have problems 24294a17dd4Sdownsj.\" with any precompiled programs, or source that assumes the 8-character 24394a17dd4Sdownsj.\" name limit and NIS. The NIS protocol mandates an 8-character username. 2447f0be37cSmmccIf you need a longer login name for email addresses, 24594a17dd4Sdownsjyou can define an alias in 2461841feddSderaadt.Pa /etc/mail/aliases . 24794a17dd4Sdownsj.It Sy fullname 248cdbdb68aSaaronThis should contain the user's first name and surname. 249cdbdb68aSaaronThe 2505a3a102aSaaron.Ql \&: 251b7797436Sderaadtis not permitted. 252fa4eb53aSmillert.It Sy login_class 253fa4eb53aSmillertThe specified user login class 254fa4eb53aSmillertmust exist in 255fa4eb53aSmillert.Pa /etc/login.conf . 25694a17dd4Sdownsj.It Sy shell 25717cfdb33SgeneOnly valid entries from the 25817cfdb33Sgene.Xr shells 5 2596f10db5aSaarondatabase or entries corresponding to 2606f10db5aSaaron.Xr pppd 8 2616f10db5aSaaronare permitted. 2624cdcf8a6Sweingart.It Sy uid_start 2636f10db5aSaaronThis value is the start of the range where free UID values are 264cdbdb68aSaaronsearched for. 265cdbdb68aSaaronThis value must be less than the value of uid_end. 2664cdcf8a6SweingartThe default value is 1000 or as configured in the configuration file. 2674cdcf8a6Sweingart.It Sy uid_end 2686f10db5aSaaronThis value is the end of the range where free UID values are 269cdbdb68aSaaronsearched for. 270cdbdb68aSaaronThis value must be more than the value of uid_start. 271dfc95624SmpechThe default value is 2147483647 or as configured in the configuration file. 27294a17dd4Sdownsj.It Sy gid/login group 2736f10db5aSaaronThis value is generated automatically, but can be specified at the 27417cfdb33Sgenediscretion of the person invoking the program. 27594a17dd4Sdownsj.It Sy password 27617cfdb33SgeneIf not empty, the password is encrypted according to 277d0159827Smillert.Xr login.conf 5 . 27817cfdb33SgeneIf empty, the account will be automatically disabled to prevent spurious 27917cfdb33Sgeneaccess to it. 28094a17dd4Sdownsj.El 28194a17dd4Sdownsj.\" .Sh UNIQUE GROUP 28294a17dd4Sdownsj.\" Perhaps you're missing what *can* be done with this scheme that falls apart 283*25a24f0bSjsg.\" with most other schemes. With each user in their own group the user can 2845a3a102aSaaron.\" safely run with a umask of 002 and have files created in their home 2855a3a102aSaaron.\" directory and not worry about others being able to read them. 28694a17dd4Sdownsj.\" 2875a3a102aSaaron.\" For a shared area you create a separate uid/gid (like cvs or ncvs on 2885a3a102aSaaron.\" freefall) you place each person that should be able to access this area 2895a3a102aSaaron.\" into that new group. 29094a17dd4Sdownsj.\" 2915a3a102aSaaron.\" This model of uid/gid administration allows far greater flexibility than 2925a3a102aSaaron.\" lumping users into groups and having to muck with the umask when working 2935a3a102aSaaron.\" in a shared area. 29494a17dd4Sdownsj.\" 29594a17dd4Sdownsj.\" I have been using this model for almost 10 years and found that it works 29694a17dd4Sdownsj.\" for most situations, and has never gotten in the way. (Rod Grimes) 29794a17dd4Sdownsj.Sh CONFIGURATION 2986931a8aaSaaron.Nm 2996f10db5aSaaronfollows these steps to extract its configuration 30017cfdb33Sgeneinformation: 3016f10db5aSaaron.Pp 3029d0b46bcSjmc.Bl -enum -offset indent -compact 3039d0b46bcSjmc.It 30417cfdb33SgeneRead internal variables. 3059d0b46bcSjmc.It 3066f10db5aSaaronRead configuration file 3079d0b46bcSjmc.Pq Pa /etc/adduser.conf . 3089d0b46bcSjmc.It 3096f10db5aSaaronParse command-line options. 31094a17dd4Sdownsj.El 3116f10db5aSaaron.Pp 3125a3a102aSaaronThe 3139682be5cSmillert.Em adduser.conf 3145a3a102aSaaronformat is explained within that file and is quite straightforward. 315a8f560c5SteduThe configuration file will be created the first time 316a8f560c5Stedu.Nm 317a8f560c5Steduis run. 31817cfdb33Sgene.\" .Sh FORMAT 31917cfdb33Sgene.\" .Bl -tag -width Ds -compact 32017cfdb33Sgene.\" .Ql Pa # 32117cfdb33Sgene.\" is a comment. 32217cfdb33Sgene.\" .P 32317cfdb33Sgene.\" .It Sy config file 3246f10db5aSaaron.\" .Nm adduser 32517cfdb33Sgene.\" reads and writes this file. 32617cfdb33Sgene.\" See /etc/adduser.conf for more details. 32717cfdb33Sgene.\" .It Sy message file 32817cfdb33Sgene.\" Eval variables in this file. See /etc/adduser.message for more 32917cfdb33Sgene.\" details. 33017cfdb33Sgene.\" .El 3319d0b46bcSjmc.Sh FILES 33229a2925cSjmc.Bl -tag -width /etc/adduser.message.bakX -compact 3339d0b46bcSjmc.It Pa /etc/master.passwd 3349d0b46bcSjmcuser database 3359d0b46bcSjmc.It Pa /etc/group 3369d0b46bcSjmcgroup database 33729a2925cSjmc.It Pa /etc/group.bak 33829a2925cSjmcbackup of original group database 3399d0b46bcSjmc.It Pa /etc/shells 3409d0b46bcSjmcshell database 3419d0b46bcSjmc.It Pa /etc/ptmp 3429d0b46bcSjmclock file for the passwd database 3439d0b46bcSjmc.It Pa /etc/adduser.conf 3449d0b46bcSjmcconfiguration file for 3459d0b46bcSjmc.Nm adduser 34629a2925cSjmc.It Pa /etc/adduser.conf.bak 34729a2925cSjmcbackup of original configuration file 3489d0b46bcSjmc.It Pa /etc/adduser.message 3499d0b46bcSjmcmessage file for 3509d0b46bcSjmc.Nm 35129a2925cSjmc.It Pa /etc/adduser.message.bak 35229a2925cSjmcbackup of original message file 3539d0b46bcSjmc.It Pa /etc/skel 3549d0b46bcSjmcskeletal login directory 3559d0b46bcSjmc.It Pa /var/log/adduser 3569d0b46bcSjmclog file for 3579d0b46bcSjmc.Nm 3589d0b46bcSjmc.El 35994a17dd4Sdownsj.Sh EXAMPLES 3606f10db5aSaaronStart 3616931a8aaSaaron.Nm 3624aa1d493Sjmcin interactive mode: 36394a17dd4Sdownsj.Pp 3644aa1d493Sjmc.Dl # adduser 36594a17dd4Sdownsj.Pp 3666f10db5aSaaronCreate user 3676f10db5aSaaron.Dq falken 3686f10db5aSaaronand 3696f10db5aSaaronlogin group 3706f10db5aSaaron.Dq falken . 3716f10db5aSaaronInvite user 3726f10db5aSaaron.Dq falken 3736f10db5aSaaroninto groups 3746f10db5aSaaron.Dq guest , 3756f10db5aSaaron.Dq staff , 3766f10db5aSaaronand 3776f10db5aSaaron.Dq beer . 3786f10db5aSaaronRealname (fullname) 3796f10db5aSaaronis 3806f10db5aSaaron.Dq Prof. Falken . 381058625b7SlumThe password has been created using 382058625b7Slum.Xr encrypt 1 : 3836d24ab64Slum.Bd -literal -offset indent 384058625b7Slum# adduser -batch falken guest,staff,beer 'Prof. Falken' \e 38540aff751Stb '$2b$10$aOadQNznQ1YJFnqNaRRneOvYvZAEO7atYiTND3EsLf6afHT5t1UIK' 386058625b7Slum.Ed 38794a17dd4Sdownsj.Pp 3886f10db5aSaaronCreate user 3896f10db5aSaaron.Dq vehlefanz 3906f10db5aSaaronin login group 3916f10db5aSaaron.Dq guest . 392cdbdb68aSaaronStart the free UID search at 5000. 393cdbdb68aSaaronNo other groups, no realname, no password. 394058625b7SlumSend a welcome message: 3956d24ab64Slum.Bd -literal -offset indent 396058625b7Slum# adduser -uid_start 5000 -group guest \e 397058625b7Slum -message /etc/adduser.message -batch vehlefanz 398058625b7Slum.Ed 399058625b7Slum.Pp 400058625b7SlumCreate user 401058625b7Slum.Dq jsmith 402058625b7Slumand place in the 403058625b7Slum.Dq jsmith 404058625b7Slumlogin group. 405058625b7SlumAlso add to the 406058625b7Slum.Dq staff 407058625b7Slumgroup. 408058625b7SlumNo password: 409058625b7Slum.Pp 410058625b7Slum.Dl "# adduser -group USER -batch jsmith staff" 41194a17dd4Sdownsj.Sh SEE ALSO 41294a17dd4Sdownsj.Xr chpass 1 , 41394a17dd4Sdownsj.Xr finger 1 , 41494a17dd4Sdownsj.Xr passwd 1 , 41594a17dd4Sdownsj.Xr setlogin 2 , 41694a17dd4Sdownsj.Xr aliases 5 , 4176f10db5aSaaron.Xr group 5 , 418fa4eb53aSmillert.Xr login.conf 5 , 41994a17dd4Sdownsj.Xr passwd 5 , 42094a17dd4Sdownsj.Xr shells 5 , 4215a3a102aSaaron.Xr nologin 8 , 42294a17dd4Sdownsj.Xr pwd_mkdb 8 , 42394a17dd4Sdownsj.Xr vipw 8 , 42494a17dd4Sdownsj.Xr yp 8 425