Command-line helper to create, modify, and delete Linux users and groups on Debian and Kali. It is meant for helpdesk and junior penetration-testing lab work on machines you administer.
- Features
- Authorized use
- Prerequisites
- Installation
- How it works
- Usage examples
- Options
- What's included
- License
- Create a user, with or without a new group
- Add an existing user to a new or existing group
- Set the login shell (
bash,zsh, or another name under/usr/bin) - Delete a user and that user's home directory, only after a
yconfirmation - Refuse to run unless you are root
- Print the matching
/etc/passwdand/etc/grouplines so you can check the result
Use this only on systems you are authorized to administer. -Ud removes the
account and /home/<username> after you answer y. There is no undo.
- Debian or Kali Linux (
adduser/addgroupare Debian-family wrappers). - Root privileges (
sudo). adduserandaddgrouponPATH.git, only for the installer below.
curl -O https://raw.githubusercontent.com/avitwil/UserManager/main/user_manager
chmod +x user_manager
sudo ./user_managerThe installer clones this repository (or updates a clone already in the
current directory), copies userman and userman.help to /usr/bin, and
removes the temporary clone. It must be run as root.
To try the command from a clone without installing it:
git clone https://github.com/avitwil/UserManager.git
cd UserManager
sudo ./userman --helpuserman --help reads /usr/bin/userman.help when that file is installed,
and the copy next to the script otherwise.
userman is a short Bash wrapper around the Debian account tools.
- It checks the effective user id and exits if you are not root.
- It accepts one account action (
-u,-U, or-Ud), an optional group (-gfor a new group,-Gfor an existing one), an optional shell (-s), or--help. - A new account goes through
adduser, which prompts for a password and the usual name and phone fields. The password is not echoed.-gcreates the group withaddgroupfirst. -s bashrunsusermod -s /usr/bin/bash. Pass the program name, not a full path.- Group changes use
usermod -aG, which adds the group and leaves the user's other groups in place. -Udasks[y/n].yrunsuserdeland then deletes that user's home directory. Any other answer stops and leaves the account as it is.- After a create or modify, the script prints the matching lines from
/etc/passwdand/etc/group.
The sessions below were run locally against the fictional account acmehelp
and group acme-staff. Numeric ids in /etc/passwd and /etc/group depend
on the machine. On Debian, adduser also adds the account to the users
group.
sudo userman --helpWithout root the script stops before it reads any account flags:
userman --helpThis script must be run as root (use sudo).
sudo userman -u acmehelp -g acme-staffadduser asks for a password (hidden) and for full name, room, and phone.
Press Enter to accept a blank field, then confirm with Y.
The script then prints the new records. This is the result from the capture above:
--------------------------------------------------------
acmehelp in /etc/passwd file
--------------------------------------------------------
acmehelp:x:1002:1002:ACME Helpdesk,,,:/home/acmehelp:/bin/bash
--------------------------------------------------------
--------------------------------------------------------
acmehelp in /etc/group file
--------------------------------------------------------
users:x:100:acmehelp
acme-staff:x:1001:acmehelp
acmehelp:x:1002:
--------------------------------------------------------
sudo userman -U acmehelp -s bash--------------------------------------------------------
acmehelp in /etc/passwd file
--------------------------------------------------------
acmehelp:x:1002:1002:ACME Helpdesk,,,:/home/acmehelp:/usr/bin/bash
--------------------------------------------------------
sudo userman -Ud acmehelpAre you sure you want to delete acmehelp and all of their files? [y/n]: y
User acmehelp and all of their files have been deleted
An answer other than y exits without deleting anything.
userman -u USER create a new user
userman -u USER -s SHELL create a user and set their shell
userman -U USER -s SHELL change an existing user's shell
userman -u USER -g GROUP create a user and a new group
userman -u USER -G GROUP create a user in an existing group
userman -U USER -g GROUP add an existing user to a new group
userman -U USER -G GROUP add an existing user to an existing group
userman -Ud USER delete a user and their home directory
userman --help show help
| Option | Description |
|---|---|
-u |
Create a new user |
-U |
Select an existing user to modify |
-Ud |
Delete an existing user and their home directory |
-g |
Create a new group and add the user to it |
-G |
Add the user to an existing group |
-s |
Set the login shell; use with -u or -U |
--help |
Show help |
Run it as root: sudo userman ....
userman— create, update, and delete users and groups, and set login shells. Installed to/usr/bin/userman.userman.help— help text foruserman --help. Installed to/usr/bin/userman.help.user_manager— installer. Clones this repository, copies the two files into/usr/bin, and removes the temporary clone.docs/screenshots/— terminal captures used in this README.
MIT — see LICENSE.
Made by Avi Twil.




