Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 4 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
add comment

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
add comment

Your Answer

 
discard

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.