Unix Technical Forum

Switch to Linux Dev Questions

This is a discussion on Switch to Linux Dev Questions within the pgsql Novice forums, part of the PostgreSQL category; --> hi all, why do i have to su to root before i su to postgres (in order to run ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:50 PM
operationsengineer1@yahoo.com
 
Posts: n/a
Default Switch to Linux Dev Questions

hi all,

why do i have to su to root before i su to postgres
(in order to run psql)? i tried to su from my
username and it asked for a password and said
authentication failed - there is no password.

i su to root and su to postgres and i my bash [i don't
know what it is called] looks like this...

sh-3.1$

what does that mean? i was expecting something like
postgres$.

i ran psql and all seems right now, but i thought this
was not a very intuitive way to get to this point.

also, i tried help in psql and when i got to the end,
i was stuck. there was no intuitive way to get out.
i just saw END with no way to do anything - i closed
the session and started again.

what can i do to avoid closing the session next time?

tia...

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:50 PM
Andrej Ricnik-Bay
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

On 5/6/06, operationsengineer1@yahoo.com <operationsengineer1@yahoo.com> wrote:
> hi all,

Hello again!


> why do i have to su to root before i su to postgres
> (in order to run psql)? i tried to su from my
> username and it asked for a password and said
> authentication failed - there is no password.

For security reasons service-accounts are commonly
password-less, and the account disabled. Usually one
achieves that with a
passwd -l <account>
That way only root is able to switch to that user if
it is (for some reason) required.


> i su to root and su to postgres and i my bash [i don't
> know what it is called] looks like this...
>
> sh-3.1$
>
> what does that mean? i was expecting something like
> postgres$.

That means that the bash you're running is not a login-shell.
Try "su - postgres" instead of "su postgres"


> i ran psql and all seems right now, but i thought this
> was not a very intuitive way to get to this point.


> also, i tried help in psql and when i got to the end,
> i was stuck. there was no intuitive way to get out.
> i just saw END with no way to do anything - i closed
> the session and started again.

\q ... it may not be "intuitive", but it's well-documented.


> what can i do to avoid closing the session next time?

See above :}

> tia...

Cheers,
Andrej



--
Please don't top post, and don't use HTML e-Mail :} Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:50 PM
operationsengineer1@yahoo.com
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

> On 5/6/06, operationsengineer1@yahoo.com
> <operationsengineer1@yahoo.com> wrote:
> > hi all,

> Hello again!
>
>
> > why do i have to su to root before i su to

> postgres
> > (in order to run psql)? i tried to su from my
> > username and it asked for a password and said
> > authentication failed - there is no password.

> For security reasons service-accounts are commonly
> password-less, and the account disabled. Usually
> one
> achieves that with a
> passwd -l <account>
> That way only root is able to switch to that user if
> it is (for some reason) required.
>
>
> > i su to root and su to postgres and i my bash [i

> don't
> > know what it is called] looks like this...
> >
> > sh-3.1$
> >
> > what does that mean? i was expecting something

> like
> > postgres$.

> That means that the bash you're running is not a
> login-shell.
> Try "su - postgres" instead of "su postgres"


thanks for the explanations. it makes sense now. no
password means one must login from root to protect the
account.

> > i ran psql and all seems right now, but i thought

> this
> > was not a very intuitive way to get to this point.

>
> > also, i tried help in psql and when i got to the

> end,
> > i was stuck. there was no intuitive way to get

> out.
> > i just saw END with no way to do anything - i

> closed
> > the session and started again.

> \q ... it may not be "intuitive", but it's
> well-documented.


actually, it wouldn't let me type anything. i believe
i tried \q b/c i am aware of it, but nothign would
type over the END that was displayed on the shell.

if it happens again, i will type \q and see if i just
missed it last time.

thanks.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 10:50 PM
Bruno Wolff III
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

On Fri, May 05, 2006 at 22:13:37 -0700,
operationsengineer1@yahoo.com wrote:
>
> why do i have to su to root before i su to postgres
> (in order to run psql)? i tried to su from my
> username and it asked for a password and said
> authentication failed - there is no password.


Note that you don't need to switch the unix user to postgres to connect
to the database as the database user postgres. Use the -U option for psql.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 10:51 PM
David
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

On Sat, May 06, 2006 at 08:27:09AM -0700, operationsengineer1@yahoo.com wrote:
> > On 5/6/06, operationsengineer1@yahoo.com
> > <operationsengineer1@yahoo.com> wrote:
> > > hi all,

> > Hello again!


> > > why do i have to su to root before i su to postgres (in order to
> > > run psql)? i tried to su from my username and it asked for a
> > > password and said authentication failed - there is no password.


> > For security reasons service-accounts are commonly password-less,
> > and the account disabled. Usually one achieves that with a passwd
> > -l <account> That way only root is able to switch to that user if it
> > is (for some reason) required.


> thanks for the explanations. it makes sense now. no
> password means one must login from root to protect the
> account.


This question has been answered quite well. However, to take it one
step further, if you want to get a bit fancy, you can su from the user
straight to postgres in one command thus:

su -c 'su postgres -c "psql blah"'

Then, when you exit psql, you drop straight back to the user instead of
root. Do note that you may have to watch out for quoting perhaps
escaping the quotes if you need quotes in the command (where I used
"psql blah"), since both the single and double quotes are being used.

Bruno Wolfe suggested using the -U option for psql, but I use 'ident
sameuser' authentication for postgres, and the -U method doesn't work
for me.

> > > also, i tried help in psql and when i got to the

> > end,
> > > i was stuck. there was no intuitive way to get

> > out.
> > > i just saw END with no way to do anything - i

> > closed
> > > the session and started again.

> > \q ... it may not be "intuitive", but it's
> > well-documented.

>
> actually, it wouldn't let me type anything. i believe
> i tried \q b/c i am aware of it, but nothign would
> type over the END that was displayed on the shell.
>
> if it happens again, i will type \q and see if i just
> missed it last time.


Actually, in this case, you're in a pager ('less' or 'more' probably)
and you simply type "q" to exit the pager. If I try "\q", it beeps on
the "\" but then exits on the "q". This is the case also (at least the
way my system is set up) when you're displaying a select query when it's
more than one screen long. pressing SPACE or PAGE DOWN (probably) will
scroll down one screen, pressing "b" or PAGE UP (probably) will scroll
up - well, if you are not familiar with the pager, find out what pager
is being used (probably "less") and check the manpage for it. There
are several features that you will find useful. You might even try "man
pager". There are several pagers and many distributions use a default
name "pager" which acts as sort of an alias for the actual pager you
use.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 10:51 PM
Stefan Lidman
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

> up - well, if you are not familiar with the pager, find out what pager
> is being used (probably "less") and check the manpage for it.


And how do set I it to less?

From 'man psql':
If the environment variable PAGER is set, the output is piped to
the specified program.

I have set that variable in my shell but psql is ignoring it and
give me more when i want less.

/Stefan Lidman

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-17-2008, 10:51 PM
David
 
Posts: n/a
Default Re: Switch to Linux Dev Questions

On Sun, May 07, 2006 at 12:05:43AM +0200, Stefan Lidman wrote:
> >up - well, if you are not familiar with the pager, find out what pager
> >is being used (probably "less") and check the manpage for it.

>
> And how do set I it to less?
>
> >From 'man psql':

> If the environment variable PAGER is set, the output is piped to
> the specified program.
>
> I have set that variable in my shell but psql is ignoring it and
> give me more when i want less.


That would probably depend upon your distro. Apparently my psql calls
/usr/bin/pager, which, on my system (Debian) is a symlink to
/etc/alternatives/pager. If this is the case of your system, you should
be able to adjust this with your alternatives system. Mine does the
update-alternatives command.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:17 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com