update for rename of docs/user/DebugKernelCrashDumps.mdwn to docs/user/list/DebugKern...
[ikiwiki.git] / docs / handbook / handbook-users-modifying.mdwn
1 \r
2 \r
3 ## 8.6 Modifying Accounts \r
4 \r
5 There are a variety of different commands available in the UNIX® environment to manipulate user accounts. The most common commands are summarized below, followed by more detailed examples of their usage.\r
6 \r
7 [[!table  data="""
8 | Command | Summary 
9  [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8) | The recommended command-line application for adding new users. 
10  [rmuser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#rmuser&section8) | The recommended command-line application for removing users. 
11  [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chpass&section1) | A flexible tool to change user database information. 
12  [passwd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#passwd&section1) | The simple command-line tool to change user passwords. 
13  [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&section8) | A powerful and flexible tool to modify all aspects of user accounts. |\r
14 """]]\r
15 ### 8.6.1 adduser \r
16 \r
17 [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8) is a simple program for adding new users. It creates entries in the system `passwd` and `group` files. It will also create a home directory for the new user, copy in the default configuration files (***dotfiles***) from `/usr/share/skel`, and can optionally mail the new user a welcome message.\r
18 \r
19 To create the initial configuration file, use `adduser -s -config_create`. [(1)](#FTN.AEN6699) Next, we configure [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8) defaults, and create our first user account, since using `root` for normal usage is evil and nasty.\r
20 \r
21  **Example 8-1. Configuring `adduser` and adding a user** \r
22 \r
23     \r
24     # adduser -v\r
25     Use option -silent if you don't want to see all warnings and questions.\r
26     Check /etc/shells\r
27     Check /etc/master.passwd\r
28     Check /etc/group\r
29     Enter your default shell: csh date no sh tcsh zsh [sh]: zsh\r
30     Your default shell is: zsh -> /usr/local/bin/zsh\r
31     Enter your default HOME partition: [/home]:\r
32     Copy dotfiles from: /usr/share/skel no [/usr/share/skel]:\r
33     Send message from file: /etc/adduser.message no\r
34     [/etc/adduser.message]: no\r
35     Do not send message\r
36     Use passwords (y/n) [y]: y\r
37     \r
38     Write your changes to /etc/adduser.conf? (y/n) [n]: y\r
39     \r
40     Ok, let's go.\r
41     Don't worry about mistakes. I will give you the chance later to correct any input.\r
42     Enter username [a-z0-9_-]: jru\r
43     Enter full name []: J. Random User\r
44     Enter shell csh date no sh tcsh zsh [zsh]:\r
45     Enter home directory (full path) [/home/jru]:\r
46     Uid [1001]:\r
47     Enter login class: default []:\r
48     Login group jru [jru]:\r
49     Login group is ***jru***. Invite jru into other groups: guest no\r
50     [no]: wheel\r
51     Enter password []:\r
52     Enter password again []:\r
53     \r
54     Name:         jru\r
55     Password: ****\r
56     Fullname: J. Random User\r
57     Uid:          1001\r
58     Gid:          1001 (jru)\r
59     Class:\r
60     Groups:       jru wheel\r
61     HOME:     /home/jru\r
62     Shell:        /usr/local/bin/zsh\r
63     OK? (y/n) [y]: y\r
64     Added user ***jru***\r
65     Copy files from /usr/share/skel to /home/jru\r
66     Add another user? (y/n) [y]: n\r
67     Goodbye!\r
68     #\r
69 \r
70 \r
71 In summary, we changed the default shell to  **zsh**  (an additional shell found in pkgsrc®), and turned off the sending of a welcome mail to added users. We then saved the configuration, created an account for `jru`, and made sure `jru` is in `wheel` group (so that she may assume the role of `root` with the [su(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#su&section1) command.)\r
72 \r
73  **Note:** The password you type in is not echoed, nor are asterisks displayed. Make sure you do not mistype the password twice.\r
74 \r
75  **Note:** Just use [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8) without arguments from now on, and you will not have to go through changing the defaults. If the program asks you to change the defaults, exit the program, and try the `-s` option.\r
76 \r
77 ### 8.6.2 rmuser \r
78 \r
79 You can use [rmuser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#rmuser&section8) to completely remove a user from the system. [rmuser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=rmuser&section=8) performs the following steps:\r
80 \r
81   1. Removes the user's [crontab(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#crontab&section1) entry (if any).\r
82   1. Removes any [at(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#at&section1) jobs belonging to the user.\r
83   1. Kills all processes owned by the user.\r
84   1. Removes the user from the system's local password file.\r
85   1. Removes the user's home directory (if it is owned by the user).\r
86   1. Removes the incoming mail files belonging to the user from `/var/mail`.\r
87   1. Removes all files owned by the user from temporary file storage areas such as `/tmp`.\r
88   1. Finally, removes the username from all groups to which it belongs in `/etc/group`.\r
89    **Note:** If a group becomes empty and the group name is the same as the username, the group is removed; this complements the per-user unique groups created by [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#adduser&section8).\r
90 \r
91 [rmuser(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#rmuser&section8) cannot be used to remove superuser accounts, since that is almost always an indication of massive destruction.\r
92 \r
93 By default, an interactive mode is used, which attempts to make sure you know what you are doing.\r
94 \r
95  **Example 8-2. `rmuser` Interactive Account Removal** \r
96 \r
97     \r
98     # rmuser jru\r
99     Matching password entry:\r
100     jru:*:1001:1001::0:0:J. Random User:/home/jru:/usr/local/bin/zsh\r
101     Is this the entry you wish to remove? y\r
102     Remove user's home directory (/home/jru)? y\r
103     Updating password file, updating databases, done.\r
104     Updating group file: trusted (removing group jru -- personal group is empty) done.\r
105     Removing user's incoming mail file /var/mail/jru: done.\r
106     Removing files belonging to jru from /tmp: done.\r
107     Removing files belonging to jru from /var/tmp: done.\r
108     Removing files belonging to jru from /var/tmp/vi.recover: done.\r
109     #\r
110 \r
111 \r
112 ### 8.6.3 chpass \r
113 \r
114 [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chpass&section1) changes user database information such as passwords, shells, and personal information.\r
115 \r
116 Only system administrators, as the superuser, may change other users' information and passwords with [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chpass&section1).\r
117 \r
118 When passed no options, aside from an optional username, [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chpass&section1) displays an editor containing user information. When the user exists from the editor, the user database is updated with the new information.\r
119 \r
120 ***'Example 8-3. Interactive `chpass` by Superuser***'\r
121 \r
122     \r
123     #Changing user database information for jru.\r
124     Login: jru\r
125     Password: *\r
126     Uid [#]: 1001\r
127     Gid [# or name]: 1001\r
128     Change [month day year]:\r
129     Expire [month day year]:\r
130     Class:\r
131     Home directory: /home/jru\r
132     Shell: /usr/local/bin/zsh\r
133     Full Name: J. Random User\r
134     Office Location:\r
135     Office Phone:\r
136     Home Phone:\r
137     Other information:\r
138 \r
139 \r
140 The normal user can change only a small subset of this information, and only for themselves.\r
141 \r
142  **Example 8-4. Interactive chpass by Normal User** \r
143 \r
144     \r
145     #Changing user database information for jru.\r
146     Shell: /usr/local/bin/zsh\r
147     Full Name: J. Random User\r
148     Office Location:\r
149     Office Phone:\r
150     Home Phone:\r
151     Other information:\r
152 \r
153 \r
154  **Note:** [chfn(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chfn&section1) and [chsh(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=chsh&section=1) are just links to [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=chpass&section=1), as are [ypchpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=ypchpass&section=1), [ypchfn(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=ypchfn&section=1), and [ypchsh(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=ypchsh&section=1). NIS support is automatic, so specifying the `yp` before the command is not necessary. If this is confusing to you, do not worry, NIS will be covered in [advanced-networking.html Chapter 19].\r
155 \r
156 ### 8.6.4 passwd \r
157 \r
158 [passwd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#passwd&section1) is the usual way to change your own password as a user, or another user's password as the superuser.\r
159 \r
160  **Note:** To prevent accidental or unauthorized changes, the original password must be entered before a new password can be set.\r
161 \r
162  **Example 8-5. Changing Your Password** \r
163 \r
164     \r
165     % passwd\r
166     Changing local password for jru.\r
167     Old password:\r
168     New password:\r
169     Retype new password:\r
170     passwd: updating the database...\r
171     passwd: done\r
172 \r
173 \r
174 ***'Example 8-6. Changing Another User's Password as the Superuser***'\r
175 \r
176     \r
177     # passwd jru\r
178     Changing local password for jru.\r
179     New password:\r
180     Retype new password:\r
181     passwd: updating the database...\r
182     passwd: done\r
183 \r
184 \r
185  **Note:** As with [chpass(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#chpass&section1), [yppasswd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=yppasswd&section=1) is just a link to [passwd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=passwd&section=1), so NIS works with either command.\r
186 \r
187 ### 8.6.5 pw \r
188 \r
189 [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#pw&section8) is a command line utility to create, remove, modify, and display users and groups. It functions as a front end to the system user and group files. [pw(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=pw&section=8) has a very powerful set of command line options that make it suitable for use in shell scripts, but new users may find it more complicated than the other commands presented here.\r
190 \r
191 #### Notes \r
192 \r
193 [[!table  data="""
194 |<tablestyle#"width:100%"> [(1)](users-modifying.html#AEN6699) | The `-s` makes [adduser(8)](http://leaf.dragonflybsd.org/cgi/web-man?commandadduser&section=8) default to quiet. We use `-v` later when we want to change defaults. |\r
195 """]]\r
196 \r
197 \r
198 CategoryHandbook\r
199 CategoryHandbook-usermanagement\r