Operating System - HP-UX
1828474 Members
2965 Online
109978 Solutions
New Discussion

Re: setting environment variables

 
SOLVED
Go to solution
Steve G. Casino
Occasional Advisor

setting environment variables

Hello Gurus

How do i go about changing a global environment variable?

for example:
typing cd fromsteve at the prompt takes me to /opt/fromsteve, I need that to point to /var/opt/fromsteve

A step by step guide would be very helpful for a newbie :-)
8 REPLIES 8
curt larson_1
Honored Contributor

Re: setting environment variables

are you sure it is
cd fromsteve

environment variables are referenced via a $
so it would be
cd $fromsteve

if there is no $, you might have an alias setup
see what typeset -f returns
Wilfred Chau_1
Respected Contributor

Re: setting environment variables

You will have to do it in /etc/profile.

alias something='command'
Steve G. Casino
Occasional Advisor

Re: setting environment variables

I don't think it is an Alias.

An alias is supposed to be just one work right? Like if i say "fromsteve" it performs the command cd /var/opt/fromsteve.

In this case it's cd fromsteve with no $
Sanjay Kumar Suri
Honored Contributor

Re: setting environment variables

Can you find out which cd you are executing with

$whereis cd

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Muthukumar_5
Honored Contributor

Re: setting environment variables

hai,

what is ll fromsteve saying.

Is it a link to /opt/fromsteve directory?

If so then,

Remove the old link
rm -f fromsteve

Create new link to /var/opt/fromsteve file
ln -s /var/opt/fromsteve fromsteve

If you do cd fromsteve

It will access all files and directories on /var/opt/fromsteve directory.

Else,

alias

what is it saying.?

Any alias are there?
Easy to suggest when don't know about the problem!
Bharat Katkar
Honored Contributor

Re: setting environment variables

Yes,
As muthukumar said, i also doubt the same.
You must be having a soft link to the directory /opt/fromsteve which was created as follows:

# ln -s /opt/fromsteve fromsteve

Now that you want to point it to /var/opt/fromsteve rerun the following command:

# unlink fromsteve
# ln -s /var/opt/fromsteve fromsteve

Hope this is the situation.
Regards,



You need to know a lot to actually know how little you know
Steve G. Casino
Occasional Advisor

Re: setting environment variables

i found no links and nothing in the aliases...

but i did something: I deleted the old directory /opt/fromsteve

when i do a "cd fromsteve" i now get directed to /var/opt/fromsteve

Muthukumar_5
Honored Contributor
Solution

Re: setting environment variables

I hope, I got it now,

what is your environment variable CDPATH saying??

echo $CDPATH

It will relocate the files / directories under their path.

Test:

[/] # CDPATH=/opt/
[/] # cd fromsteve

It will go to /opt/fromsteve
where [/] shows PWD

[/] # CDPATH=/var/opt/
[/] # export $CDPATH
[/] # cd fromsteve
/var/opt/fromsteve
[/var/opt/fromsteve] #

It will go to /var/opt/fromsteve

HTH.

Regards
Muthu
Easy to suggest when don't know about the problem!