Neben dem Anlegen von Usern, muss man auch User entfernen können, dies geht mit dem Befehl userdel.
Syntax von userdel:
userdel [-D binddn] [-P path] [-r[-f]]
[–service service] [–help] [-u] [-v] account
userdel entfernt einen Benutzeraccount vom lokalen Dateisystem oder einer ldap-Datenbank und löscht alle zugehörigen Einträge, die in der Gruppendatenbank vorhanden sind. Bevor der User gelöscht wird, wird noch USERDEL_PRECMD aufgerufen, während USERDEL_POSTCMD nach dem Entfernen des Users aufgerufen wird.
Optionen:
-r, –remove-home
Remove the whole home directory and the mail spool of the specified account. Files located in other directories will have to be searched for and deleted manually.
-f, –force
This option is used to force the removal of files, even if not owned by the account.
–service service
Add the account to a special directory. The default is files, but ldap is also valid.
-D, –binddn binddn
Use the Distinguished Name binddn to bind to the LDAP directory. The user will be prompted for a password for simple authentication.
-P, –path path
The passwd and shadow files are located below the specified directory path. chpasswd will use this files, not /etc/passwd and /etc/shadow.
–help Print a list of valid options with a short description.
-u, –usage
Print a short list of valid options.
-v, –version
Print the version number and exit.
Beispiel: userdel -r username
Der Benutzer mit dem Namen username wird aus den Dateien /etc/passwd und /etc/group entfernt, mit der Option -r wird das zugehörige Home-Verzeichnis ebenfalls gelöscht.
Hier geht es zum Artikel wie man einen User anlegt.