To limit the output to the username only, simply do the following either from the
psql shell or from the local shell/terminal as
psql -c "SELECT u.usename AS "User Name" FROM pg_catalog.pg_user u;"
While the quick method, as pointed out in a previous answer, displays 3 columns; including User Name, List of Roles Attributes, and Member of role group(s).
psql -c "\du"
Finally, as pointed out in a subsequent answer, the PostgreSQL commands run in the background for the
\du command show those "default" columns by calling:
SELECT u.usename AS "User name",
u.usesysid AS "User ID",
CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('superuser, create
database' AS pg_catalog.text)
WHEN u.usesuper THEN CAST('superuser' AS pg_catalog.text)
WHEN u.usecreatedb THEN CAST('create database' AS
ELSE CAST('' AS pg_catalog.text)
END AS "Attributes"
FROM pg_catalog.pg_user u
ORDER BY 1;
(what psql does behind the scenes when you type \du)
The last part was copied from the PostgreSQL Mailing List.