shlogg · Early preview
Dbvisualizer @dbvis-marketing

List PostgreSQL Users Via PSQL & SQL Queries

List PostgreSQL users via `psql` terminal using `\du` command or query `pg_user` view for structured info. Display superusers with `SELECT * FROM pg_catalog.pg_user WHERE usesuper = true;`. Ensure security by authenticating users.

Managing database users is a core task for any administrator. PostgreSQL offers two straightforward methods to list users: via the psql terminal and by querying the database. This guide walks you through both approaches.

  
  
  Listing users in PostgreSQL

  
  
  Use the psql command

The psql terminal lets you directly manage and query your database.
Connect to PostgreSQL
Use this command to log in.

psql -U <username>

    
    

    
    




Run the Command
Enter this command for a list of users.

\du

    
    

    
    




Or this for detailed output:

\du+...