how do delete a user from command line

admin0

Verified User
Joined
Nov 14, 2008
Messages
23
While deleting an user, ( due to root doing cd in the folder) a user was not deleted properly. He does not have a home directory, but appears as a zombie in the UI not allowing me to click or do anything. Screenshot attached.

How do I delete the user/entry ?
 

Attachments

  • Screenshot from 2020-07-12 23-41-20.png
    Screenshot from 2020-07-12 23-41-20.png
    19.7 KB · Views: 262
You can try adding the user again or if that can't be done remove the the user files from /usr/local/directadmin/data/users and remove the show_all_users_cache from /usr/local/directadmin/data/admin and delete the user from /etc/passwd, /etc/shadow, /etc/gshadow, and /etc/group.

Then add the user again and remove to get everything else.
 
You can try adding the user again or if that can't be done remove the the user files from /usr/local/directadmin/data/users and remove the show_all_users_cache from /usr/local/directadmin/data/admin and delete the user from /etc/passwd, /etc/shadow, /etc/gshadow, and /etc/group.

Then add the user again and remove to get everything else.
This way ...

 
This way ...


I think this one should be included in directadmin CLI command.

Example, we can trigger this:

da-cli --remove-user <username>

Please vote this: https://feedback.directadmin.com/b/feature-requests/include-directadmin-cli-commands/
 
i seem to have problem deleting the domain, i assume the domain must still be somewhere right?
 
You can try adding the user again or if that can't be done remove the the user files from /usr/local/directadmin/data/users and remove the show_all_users_cache from /usr/local/directadmin/data/admin and delete the user from /etc/passwd, /etc/shadow, /etc/gshadow, and /etc/group.

Then add the user again and remove to get everything else.
Do NOT follow these instructions!

remove the show_all_users_cache from /usr/local/directadmin/data/admin

Instead remove the entry for the user from that file.
 
Because it's better/safer not to mess with passwd files etc. if it can be done easier with 1 command and have the system do it for you.
Less chance of mistakes. ;)

But he didn't give the system command to do that. I don't even know the command. I have always edited those files.
 
show_all_users_cache
It's just a cache, so it can safely remove this file. don't need to waste time to edit the file.

It will regenerate when you open the list users page again.


Other thing, in "/etc/" relate to the user data. it can remove with "userdel" command.

Code:
userdel -r zombieuser
 
But he didn't give the system command to do that.
Correct, because @MaXi32 already gave that command.

And normally the userdel should take care of all things if the da-cli command would not be sufficient, so no need editting these files anyway normally.
 
Correct, because @MaXi32 already gave that command.

And normally the userdel should take care of all things if the da-cli command would not be sufficient, so no need editting these files anyway normally.

That's ok but one shouldn't act like something is wrong with my suggestion. It does work. If there is an easier that's fine. One can make that suggestion but leave mine alone. If one is scared to edit files then start another hobby.
 
but one shouldn't act like something is wrong with my suggestion
It wasn't said it's wrong anywhere, it was just said to -not- use these instructions.
And I'm sorry but I agree with that advise.
What you're doing is in fact something for specialized users, or at least have a lot of knowledge only. Even I have enough knowledge but wouldn't edit these files if not absolutely necessary, they are quite dangerous.

If one is scared to edit files then start another hobby.
You also normally don't edit .dll files in Windows or for example .cfg or .ini files for games while you in fact you often can. Being scared has nothing to do with it, being safe has.

Also there are loads of hobbyists with little knowledge and a personal license or starting hosters and a lot of hosters who came from cPanel not used to working via console.

It's not that other methods mentioned are easier, they are just way more safe. And again, it wasn't told that yours was wrong, it was just said not to follow that instruction. I personally might have stated that "it's better to not use those instructions" instead of what's now only said "not", but not everybody knows great English here. Next to that, it wouldn't have mattered a lot.
People can choose anyway what advise to use.
 
It wasn't said it's wrong anywhere, it was just said to -not- use these instructions.

Well here in the US when NOT is in all caps like it means it's wrong.

And whether something is safe or not is a matter of perspective. I choose to edit a file because then I know exactly what is happening and what I need to do to put it back the way it was. I always make a backup of the file. If I use userdel I don't know what the command is doing unless I research it. I have never liked it when things are done for me without me knowing exactly what is being done. That is why we have problems like Crowdstrike.

If I manually edit /etc/passwd then I know exactly what I did and how to put it back the way it was. If I use userdel and decide I need that user again and use useradd then the user gets a new user id number and permissions are still screwed up because technically it really a different user not the same user. But if I manually edit the file permissions are fine because I added the user back exactly the way it was.

Manually editing files is not as convenient but I do consider it safer because commands that do things for you might not do what you think they do. I always edit the options file manually for custombuild. I don't use the da commands to do it.

I will do automatic things when I have to. I do yum updates and so forth. But I am always holding my breath when I do. I am always wondering what is going to break. I don't even like rebooting. I don't consider it safe but necessary.
 
Well here in the US when NOT is in all caps like it means it's wrong.
I doubt that very much. Capitalizing words is making the statement stronger, it does not change the meaning of something. Seems rather an personal interpretation than a real thing.

What you choose is your own responsibility ofcourse.
And you might consider it safe, but that does not mean that it generally is, maybe for you, bot not for most people. For most it's not. And even you can make a typo or maybe leave a space by accident.
Changing 4 files is 4 times an option for an error. And a system command rarely has issues compared to manual entry's.

If I use userdel I don't know what the command is doing unless I research it.
Userdel is basic linux knowledge. Needs research 1 command. What you are doing one needs to know what all those seperate files do.
So that is not an argument.

I also still change custombuild manually, but that is a .conf file meaning a configuration file, not a system file.

As for the last alinea.... in any system anything can go wrong. Not booting can be just as riskfull as booting, but I don't consider anything of that kind safe but rather "kind of safe". Same with updates of any kind. We've also seen enough DA updates with issues. ;)
 
I doubt that very much. Capitalizing words is making the statement stronger, it does not change the meaning of something. Seems rather an personal interpretation than a real thing.

Dude I live here. You don't. When you tell somebody to not do something whether its capitalized or not it's a warning that something bad could happen if you proceed. That is just basic English which I know is not your primary language but still it's very basic.

I consider something safe if I know how to backtrack and reverse it. Manually editing is always safer because you can first make a backup of the file and restore it if necessary. I don't care if it's a .conf file or a .dll file.

If I use userdel to delete a user there is no way to reverse that. Adding the user again with useradd will not reverse it. There is no command that will reverse it.

And you might consider it safe, but that does not mean that it generally is, maybe for you, bot not for most people. For most it's not. And even you can make a typo or maybe leave a space by accident.
Changing 4 files is 4 times an option for an error. And a system command rarely has issues compared to manual entry's.

That is why you backup the file first.

If you think another way is safer then I will give you that. That is a personal matter. What is safe for me is not the same for everyone. I still login to all my servers as root which they say is not safe but I think it is safe for me. Safety is relative to the person.
 
Dude I live here. You don't.
Dude, keep your respect and don't call me dude. I'm much older than you.
And you might live there but I have enough friends there, also some who live there too.

whether its capitalized or not it's a warning that something bad could happen if you proceed. That is just basic English which I know is not your primary language but still it's very basic.
EXACTLY! So you agree with me here. Because something bad -could- happen. It does not say it's -wrong- like you said. I know basic English and I know English probably much longer than you age wise. And with this explanation, you prooved me correct.

I will stop this discussion as it has totally no use anymore and I don't like the disrespect and we keep running in circles anyway.
 
Back
Top