Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
Didn't think about the shadow file. Cool, this worked, thanks! – Cimm Sep 9 '10 at 8:38
For future reference: It may be useful to check the /etc/group file as well, had the same typo there. – Cimm Sep 9 '10 at 9:31

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

root@panic:/# useradd test?test
root@panic:/# userdel test\?test
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.