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
However you can also display all users by cut -d ":" -f 1 /etc/passwd.