Remove a Linux user with only his UID
8,415
Solution 1
Just delete the appropriate lines in /etc/passwd and /etc/shadow, and the home directory.
Solution 2
The '?' needs to be escaped. I've verified that the following works:
root@panic:/# useradd test?test root@panic:/# userdel test\?test
Related videos on Youtube
Author by
Cimm
Intrigued by the web and its potential, convinced it will keep reinventing itself and happy to be part of that. Feels there is not enough time to build all the applications he comes up with.
Updated on September 17, 2022Comments
-
Cimm almost 2 years
I would like to remove (or rename) an Ubuntu user I created but the usual solutions don't work as there is a question mark in the username.
$ sudo usermod -l myuser my?user usermod: user 'my?user' does not exist
I tried with the usual quotes and/or a backslash before the question mark but to no avail.
Is there a way to remove a user based on his UID? That would be a solution as I don't need to enter the username.
Thanks!
-
Cimm almost 14 yearsDidn't think about the shadow file. Cool, this worked, thanks!
-
Cimm almost 14 yearsFor future reference: It may be useful to check the
/etc/group
file as well, had the same typo there. -
Cimm almost 14 yearsThanks Scott, I think Sven's solution is nicer. His solution makes it possible to change the username without removing.