LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Problem with sudo in Redhat 5 (https://www.linuxquestions.org/questions/linux-server-73/problem-with-sudo-in-redhat-5-a-940377/)

ssuhaib 04-18-2012 12:10 AM

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.

EricTRA 04-18-2012 01:00 AM

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

ssuhaib 04-18-2012 01:48 AM

Thanks Erictra,

I declared the variable in .bashrc and it is working ! Lesson learnt: add vairables for users logging using sudo in .bashrc.

EricTRA 04-18-2012 01:52 AM

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


All times are GMT -5. The time now is 02:40 AM.