1

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
  • 123
  • 1
  • 7

2 Answers2

9

Just delete the appropriate lines in /etc/passwd and /etc/shadow, and the home directory.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • Didn't think about the shadow file. Cool, this worked, thanks! – Cimm Sep 09 '10 at 08:38
  • 1
    For future reference: It may be useful to check the `/etc/group` file as well, had the same typo there. – Cimm Sep 09 '10 at 09:31
3

The '?' needs to be escaped. I've verified that the following works:

root@panic:/# useradd test?test
root@panic:/# userdel test\?test
blacktip
  • 301
  • 1
  • 2
  • 5
  • Thanks Scott, I think Sven's solution is nicer. His solution makes it possible to change the username without removing. – Cimm Sep 13 '10 at 12:17