Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Is there a command to list all users? Also to add, delete, modify users, in the terminal?

I need a command to list all users as well as commands to add, delete and modify users from terminal - any commands that could help in administrating user accounts easily by terminal.
by

2 Answers

akshay1995
Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

cat /etc/passwd

OR

less /etc/passwd
more /etc/passwd

You can also use awk:awk

awk -F':' '{ print $1}' /etc/passwd
RoliMishra
o get a list of all users you type (as users are listed in /etc/passwd)

getent passwd

To add a user newuser to the system you would type

sudo adduser newuser

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

sudo adduser anyuser cdrom

You delete a user (for instance obsolete) with

sudo deluser obsolete

If you want to delete his home directory/mails as well you type

sudo deluser --remove-home obsolete

And

sudo deluser --remove-all-files obsolete

will remove the user and all files owned by this user on the whole system.

Login / Signup to Answer the Question.