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       -P, --prefix PREFIX_DIR
48           Apply changes in the PREFIX_DIR directory and use the configuration
49           files from the PREFIX_DIR directory. This option does not chroot
50           and is intended for preparing a cross-compilation target. Some
51           limitations: NIS and LDAP users/groups are not verified. PAM
52           authentication is using the host files. No SELINUX support.
53
54       -Z, --selinux-user
55           Remove any SELinux user mapping for the user's login.
56

CONFIGURATION

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

FILES

140       /etc/group
141           Group account information.
142
143       /etc/login.defs
144           Shadow password suite configuration.
145
146       /etc/passwd
147           User account information.
148
149       /etc/shadow
150           Secure user account information.
151
152       /etc/subgid
153           Per user subordinate group IDs.
154
155       /etc/subuid
156           Per user subordinate user IDs.
157

EXIT VALUES

159       The userdel command exits with the following values:
160
161       0
162           success
163
164       1
165           can't update password file
166
167       2
168           invalid command syntax
169
170       6
171           specified user doesn't exist
172
173       8
174           user currently logged in
175
176       10
177           can't update group file
178
179       12
180           can't remove home directory
181

CAVEATS

183       userdel will not allow you to remove an account if there are running
184       processes which belong to this account. In that case, you may have to
185       kill those processes or lock the user's password or account and remove
186       the account later. The -f option can force the deletion of this
187       account.
188
189       You should manually check all file systems to ensure that no files
190       remain owned by this user.
191
192       You may not remove any NIS attributes on a NIS client. This must be
193       performed on the NIS server.
194
195       If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will
196       delete the group with the same name as the user. To avoid
197       inconsistencies in the passwd and group databases, userdel will check
198       that this group is not used as a primary group for another user, and
199       will just warn without deleting the group otherwise. The -f option can
200       force the deletion of this group.
201

SEE ALSO

203       chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8),
204       groupdel(8), groupmod(8), subgid(5), subuid(5), useradd(8), usermod(8).
205
206
207
208shadow-utils 4.6                  11/08/2018                        USERDEL(8)
Impressum