Thread: 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
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
> 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
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.
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.
> 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
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.