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:
To change the details for a user (for example real name):
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
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.
list of all users who can login (no system users like: bin,deamon,mail,sys, etc.)
add new user
If you want to delete the home directory (default the directory /home/username)
If you want to delete all files from the system from this user (not only is the home diretory)
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.
This should get, under most normal situations, all normal (non-system, not weird, etc) users:
This works by:
This is because on many linux systems, usernames above 1000 are reserved for unprivileged (you could say normal) users. Some info on this here:
To find out the users which have home-directories in the /home-folder on the machine, run the following commands
You can then see the users who have authorization to log into the server. If we want to look into the files of any users, you must be the root user.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?