How to display all user and groups by command

You can display with the help of compgen builtin command as follows:

To display all users run following command:

 compgen -u

To display all groups run following command:

compgen -g

You may also like...