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           Note: This option is dangerous and may leave your system in an
29           inconsistent state.
30
31       -h, --help
32           Display help message and exit.
33
34       -r, --remove
35           Files in the user's home directory will be removed along with the
36           home directory itself and the user's mail spool. Files located in
37           other file systems will have to be searched for and deleted
38           manually.
39
40           The mail spool is defined by the MAIL_DIR variable in the
41           login.defs file.
42
43       -R, --root CHROOT_DIR
44           Apply changes in the CHROOT_DIR directory and use the configuration
45           files from the CHROOT_DIR directory.
46
47       -Z, --selinux-user
48           Remove any SELinux user mapping for the user's login.
49

CONFIGURATION

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

FILES

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

EXIT VALUES

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

CAVEATS

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

SEE ALSO

190       chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8),
191       groupdel(8), groupmod(8), useradd(8), usermod(8).
192
193
194
195shadow-utils 4.1.5.1              03/14/2019                        USERDEL(8)
Impressum