1USERDEL(8)                System Management Commands                USERDEL(8)
2
3
4

NAME

6       userdel - delete a user account and related files
7

SYNOPSIS

9       userdel [options] LOGIN
10

DESCRIPTION

12       The userdel command modifies the system account files, deleting all
13       entries that refer to the user name LOGIN. The named user must exist.
14

OPTIONS

16       The options which apply to the userdel command are:
17
18       -f, --force
19           This option forces the removal of the user account, even if the
20           user is still logged in. It also forces userdel to remove the
21           user´s home directory and mail spool, even if another user uses the
22           same home directory or if the mail spool is not owned by the
23           specified user. If USERGROUPS_ENAB is defined to yes in
24           /etc/login.defs and if a group exists with the same name as the
25           deleted user, then this group will be removed, even if it is still
26           the primary group of another user.
27
28
29           Note: This option is dangerous and may leave your system in an
30           inconsistent state.
31
32       -h, --help
33           Display help message and exit.
34
35       -r, --remove
36           Files in the user´s home directory will be removed along with the
37           home directory itself and the user´s mail spool. Files located in
38           other file systems will have to be searched for and deleted
39           manually.
40
41           The mail spool is defined by the MAIL_DIR variable in the
42           login.defs file.
43

CONFIGURATION

45       The following configuration variables in /etc/login.defs change the
46       behavior of this tool:
47
48       MAIL_DIR (string)
49           The mail spool directory. This is needed to manipulate the mailbox
50           when its corresponding user account is modified or deleted. If not
51           specified, a compile-time default is used.
52
53       MAIL_FILE (string)
54           Defines the location of the users mail spool files relatively to
55           their home directory.
56
57       The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod, and
58       userdel to create, move, or delete the user´s mail spool.
59
60       If MAIL_CHECK_ENAB is set to yes, they are also used to define the MAIL
61       environment variable.
62
63       MAX_MEMBERS_PER_GROUP (number)
64           Maximum members per group entry. When the maximum is reached, a new
65           group entry (line) is started in /etc/group (with the same name,
66           same password, and same GID).
67
68           The default value is 0, meaning that there are no limits in the
69           number of members in a group.
70
71           This feature (split group) permits to limit the length of lines in
72           the group file. This is useful to make sure that lines for NIS
73           groups are not larger than 1024 characters.
74
75           If you need to enforce such limit, you can use 25.
76
77           Note: split groups may not be supported by all tools (even in the
78           Shadow toolsuite). You should not use this variable unless you
79           really need it.
80
81       USERDEL_CMD (string)
82           If defined, this command is run when removing a user. It should
83           remove any at/cron/print jobs etc. owned by the user to be removed
84           (passed as the first argument).
85
86           The return code of the script is not taken into account.
87
88           Here is an example script, which removes the user´s cron, at and
89           print jobs:
90
91               #! /bin/sh
92
93               # Check for the required argument.
94               if [ $# != 1 ]; then
95                    echo "Usage: $0 username"
96                    exit 1
97               fi
98
99               # Remove cron jobs.
100               crontab -r -u $1
101
102               # Remove at jobs.
103               # Note that it will remove any jobs owned by the same UID,
104               # even if it was shared by a different username.
105               AT_SPOOL_DIR=/var/spool/cron/atjobs
106               find $AT_SPOOL_DIR -name "[^.]*" -type f -user $1 -delete \;
107
108               # Remove print jobs.
109               lprm $1
110
111               # All done.
112               exit 0
113
114
115
116       USERGROUPS_ENAB (boolean)
117           Enable setting of the umask group bits to be the same as owner bits
118           (examples: 022 -> 002, 077 -> 007) for non-root users, if the uid
119           is the same as gid, and username is the same as the primary group
120           name.
121
122           If set to yes, userdel will remove the user´s group if it contains
123           no more members, and useradd will create by default a group with
124           the name of the user.
125

FILES

127       /etc/group
128           Group account information.
129
130       /etc/login.defs
131           Shadow password suite configuration.
132
133       /etc/passwd
134           User account information.
135
136       /etc/shadow
137           Secure user account information.
138

EXIT VALUES

140       The userdel command exits with the following values:
141
142       0
143           success
144
145       1
146           can´t update password file
147
148       2
149           invalid command syntax
150
151       6
152           specified user doesn´t exist
153
154       8
155           user currently logged in
156
157       10
158           can´t update group file
159
160       12
161           can´t remove home directory
162

CAVEATS

164       userdel will not allow you to remove an account if there are running
165       processes which belong to this account. In that case, you may have to
166       kill those processes or lock the user´s password or account and remove
167       the account later. The -f option can force the deletion of this
168       account.
169
170       You should manually check all file systems to ensure that no files
171       remain owned by this user.
172
173       You may not remove any NIS attributes on a NIS client. This must be
174       performed on the NIS server.
175
176       If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will
177       delete the group with the same name as the user. To avoid
178       inconsistencies in the passwd and group databases, userdel will check
179       that this group is not used as a primary group for another user, and
180       will just warn without deleting the group otherwise. The -f option can
181       force the deletion of this group.
182

SEE ALSO

184       chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8),
185       groupdel(8), groupmod(8), useradd(8), usermod(8).
186
187
188
189System Management Commands        07/24/2009                        USERDEL(8)
Impressum