I need a command to list all users in terminal. And how to add, delete, modify users from terminal.
That could help in administrating your accounts easily by terminal.
To list all users you can use:
To add a new user you can use:
To remove/delete a user, first you can use:
Then you may want to delete the home directory for the deleted user account :
sudo rm -r /home/username
(Please use with caution the above command!)
To modify the username of a user:
To change the password for a user:
To change the shell for a user:
And, of course, see also:
Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
You can also use awk:awk
Ok here is a trick that will help you sort this. The terminal has auto completion if you type user and hit Tab key twice it will list all the commands that exist with user as the first 4 chars.
gives me as possible options
useradd userdel usermod users users-admin
to list users you should go with what Mitch said.
Hope that helps I love tab completion in bash saves me from remembering things.
The easiest way to get this kind of information is
To get a list of all users you type (as users are listed in
To add a user newuser to the system you would type
to create a user that has all default settings applied.
Bonus: To add any user (for instance anyuser) to a group (for instance cdrom) type
You delete a user (for instance obsolete) with
If you want to delete his home directory/mails as well you type
will remove the user and all files owned by this user on the whole system.