LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-04-2008, 01:39 AM   #1
Fond_of_Opensource
Member
 
Registered: May 2006
Posts: 55

Rep: Reputation: 15
Unhappy command command su or sudo


hi all,


In my redhat linux system, I have a useraccount as 'postgres'


PGDATA is an environment variable in postgres user account.

How can I get the value of $PGDATA environment variable from root prompt suing 'su' or 'sudo' command.


I want to do something like this.


From postgres user account ,

I can get
Code:
     root# su - postgres
     -bash-2.05b$ echo $PGDATA
     /var/lib/pgsql/data
The same output I want from the command line of root prompt using su or sudo command.


Please help.

Thanks in advance
 
Old 04-04-2008, 04:12 AM   #2
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Couldn't you add something like this to /root/.bashrc

Code:
export PGDATA= /var/lib/pgsql/data
 
Old 04-06-2008, 11:40 PM   #3
Fond_of_Opensource
Member
 
Registered: May 2006
Posts: 55

Original Poster
Rep: Reputation: 15
Unhappy

No. I can't add it to .bashrc because the env variable PGDATA changes with every login.



Please help....
 
Old 04-07-2008, 12:16 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Just a thought:

Can't you echo the PGDATA to a file when the postgres user logs in?
Next root should be able to read that file.

Last edited by Wim Sturkenboom; 04-07-2008 at 06:40 AM. Reason: fixed typo
 
Old 04-07-2008, 01:31 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by Fond_of_Opensource View Post
because the env variable PGDATA changes with every login.
What?


Cheers,
Tink
 
Old 04-07-2008, 11:45 PM   #6
Fond_of_Opensource
Member
 
Registered: May 2006
Posts: 55

Original Poster
Rep: Reputation: 15
I meant to say the env variable PGDATA differs from system to system.(sorry, not related to login).
 
Old 04-08-2008, 01:19 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I don't know how RH deals with this, but normally I'd be
looking for a script in /etc/profile.d ... that's how it
works in Slackware, anyway.


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo command not working. rock.k Linux - Newbie 2 02-27-2008 08:26 PM
Sudo Apt-get command use. Mr.Carioca Linux - Distributions 1 02-09-2008 07:05 PM
sudo command boy_to_man Linux - Newbie 1 01-05-2007 01:45 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
SUDO Command help TPAWired Linux - Software 3 08-15-2005 01:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration