Identify Login User & Permissions

Started by Carlos Mennensover 15 years ago6 messagesgeneral
Jump to latest
#1Carlos Mennens
carlos.mennens@gmail.com

I can't find in the docs or using Google how one can identify which
user is currently logged in to psql. I search for the command that if
for some reason I forget which user I am logged in as, rather than
logging out of PostgreSQL, there has to be a command that shows me who
I am and also what kind of special permissions my current user has.
Can anyone please assist me or point me in the right direction?

#2Guillaume Lelarge
guillaume@lelarge.info
In reply to: Carlos Mennens (#1)
Re: Identify Login User & Permissions

Le 14/09/2010 22:01, Carlos Mennens a �crit :

I can't find in the docs or using Google how one can identify which
user is currently logged in to psql. I search for the command that if
for some reason I forget which user I am logged in as, rather than
logging out of PostgreSQL, there has to be a command that shows me who
I am and also what kind of special permissions my current user has.
Can anyone please assist me or point me in the right direction?

SELECT current_user;

--
Guillaume
http://www.postgresql.fr
http://dalibo.com

#3Carlos Mennens
carlos.mennens@gmail.com
In reply to: Guillaume Lelarge (#2)
Re: Identify Login User & Permissions

On Tue, Sep 14, 2010 at 4:23 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:

SELECT current_user;

Thanks. That worked well:

postgres=# SELECT current_user;
current_user
--------------
carlos
(1 row)

Do you know how I can verify what privileges or permissions 'carlos'
has granted to him in PostgreSQL?

#4Richard Broersma
richard.broersma@gmail.com
In reply to: Carlos Mennens (#1)
Re: Identify Login User & Permissions

On Tue, Sep 14, 2010 at 1:01 PM, Carlos Mennens
<carlos.mennens@gmail.com> wrote:

I can't find in the docs or using Google how one can identify which
user is currently logged in to psql. I search for the command that if
for some reason I forget which user I am logged in as, rather than
logging out of PostgreSQL, there has to be a command that shows me who
I am and also what kind of special permissions my current user has.
Can anyone please assist me or point me in the right direction?

I don't have the entire answer. But here is a place to start:

http://www.postgresql.org/docs/9.0/static/functions-info.html

Note that there is a slight distinction between current_user and session_user.

postgres=> select user, current_user, session_user;
current_user | current_user | session_user
--------------+--------------+--------------
broersr | broersr | broersr
(1 row)

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

#5Richard Broersma
richard.broersma@gmail.com
In reply to: Carlos Mennens (#3)
Re: Identify Login User & Permissions

On Tue, Sep 14, 2010 at 1:28 PM, Carlos Mennens
<carlos.mennens@gmail.com> wrote:

Do you know how I can verify what privileges or permissions 'carlos'
has granted to him in PostgreSQL?

psql has its own commands.

for example if i was to see the owner of all:

users:
db=> \du

schemas:
db=> \dn

tables/views:
db => \d

other useful commands:
db => \?

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

#6Guillaume Lelarge
guillaume@lelarge.info
In reply to: Carlos Mennens (#3)
Re: Identify Login User & Permissions

Le 14/09/2010 22:28, Carlos Mennens a �crit :

On Tue, Sep 14, 2010 at 4:23 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:

SELECT current_user;

Thanks. That worked well:

postgres=# SELECT current_user;
current_user
--------------
carlos
(1 row)

Do you know how I can verify what privileges or permissions 'carlos'
has granted to him in PostgreSQL?

You need to check many things on the catalogs to know that. You won't
find a single command to do that.

--
Guillaume
http://www.postgresql.fr
http://dalibo.com