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
44       -R, --root CHROOT_DIR
45           Apply changes in the CHROOT_DIR directory and use the configuration
46           files from the CHROOT_DIR directory.
47
48       -Z, --selinux-user
49           Remove any SELinux user mapping for the user´s login.
50

CONFIGURATION

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

FILES

134       /etc/group
135           Group account information.
136
137       /etc/login.defs
138           Shadow password suite configuration.
139
140       /etc/passwd
141           User account information.
142
143       /etc/shadow
144           Secure user account information.
145

EXIT VALUES

147       The userdel command exits with the following values:
148
149       0
150           success
151
152       1
153           can´t update password file
154
155       2
156           invalid command syntax
157
158       6
159           specified user doesn´t exist
160
161       8
162           user currently logged in
163
164       10
165           can´t update group file
166
167       12
168           can´t remove home directory
169

CAVEATS

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

SEE ALSO

191       chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8),
192       groupdel(8), groupmod(8), useradd(8), usermod(8).
193
194
195
196shadow-utils 4.1.5.1              05/10/2016                        USERDEL(8)
Impressum