LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-18-2012, 12:10 AM   #1
ssuhaib
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Rep: Reputation: 1
Problem with sudo in Redhat 5


Hi Gurus,

I login as a user, do "sudo su", change to userid 'root' and add the value in .bash_profile. I exit after this, login as a user, sudo to root, but echo $variable does not show any value although the value of the variable exist in .bash_profile in root home directory (/root).

Any help with is welcome.

Thanks in advance.
 
Old 04-18-2012, 01:00 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

Did you export the variable or just declare it? If you declare a variable in .bashrc/.bash_profile you should export it if you want to use it in login shells.
Code:
export VARIABLE="value"
Read this for clarification: Bash Beginners Guide

Kind regards,

Eric
 
1 members found this post helpful.
Old 04-18-2012, 01:48 AM   #3
ssuhaib
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Original Poster
Rep: Reputation: 1
Thanks Erictra,

I declared the variable in .bashrc and it is working ! Lesson learnt: add vairables for users logging using sudo in .bashrc.
 
Old 04-18-2012, 01:52 AM   #4
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

Nice! Also remember that if you didn't export the variable (you only mention declaring it), it will no be available in any sub-shells created. If you consider your problem solved then please mark your thread as such.

Kind regards,

Eric
 
1 members found this post helpful.
  


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
LXer: The Ultimate Sudo FAQ To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Redhat LINUX el5 _ sudo + Id commad error panneer_dxb Linux - Enterprise 3 05-08-2011 05:41 AM
Problem with SUDO : sudo: pam_authenticate: Module is unknown cristoph_ Linux - Software 2 03-02-2009 07:12 PM
Slackware 12.0: boot problem & sudo / wifi-radar problem War_Ensemble Slackware 7 01-15-2008 09:49 AM
correct sudo logging in RedHat sancho5 Linux - General 1 05-07-2004 08:52 AM


All times are GMT -5. The time now is 07:26 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration