LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   setting PATH variable. (http://www.linuxquestions.org/questions/linux-newbie-8/setting-path-variable-4175422205/)

HarryBoy 08-15-2012 09:49 AM

setting PATH variable.
 
I have SUSE Linux and I'm trying to set my path variable.

I have added:
Code:

PATH=$PATH:/home/mynewDirectory/
export PATH

When I echo $PATH this is now appended to the PATH variable.

I want this to remain always so I added the above to both the
Code:

/home/username/.bashrc
/home/username/.profile

But when I start up a new shell using putty I see that the PATH is not set to what I want.

Why is this??

guruprasadpr 08-15-2012 11:13 AM

Hi
It might be the case that your profile file is one of the those in which you had made entries.

Please let us know the output of this in your login shell:

Code:

echo $SHELL
Guru.

HarryBoy 08-15-2012 11:34 AM

Thanks the output is:

Quote:

/bin/bash

Reuti 08-15-2012 11:38 AM

Do you have additional initialization files like ~/.bash_profile or ~/.bash_login?

HarryBoy 08-15-2012 12:10 PM

nope just .bash_history

Thanks

John VV 08-15-2012 01:27 PM

opensuse 12.1 uses a "local" version of those files
Quote:

# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...
so please EDIT that file and NOT this one
edit "/etc/profile.local"
the same goes for
Quote:

# /etc/bash.bashrc for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/bash.bashrc There are chances that your changes
# will be lost during system upgrades. Instead use /etc/bash.bashrc.local
# for bash or /etc/ksh.kshrc.local for ksh or /etc/zsh.zshrc.local for the
# zsh or /etc/ash.ashrc.local for the plain ash bourne shell for your local
# settings, favourite global aliases, VISUAL and EDITOR variables, etc ...
suse makes use OF TONES and TONES of scripts that will REWRITE those std files

arizonagroovejet 08-15-2012 01:37 PM

If you edit the files in /etc/ as John VV suggests that will apply the setting for all users.

If you just want to do it for your own usercode then make yourself a .bash_profile file and put the PATH declaration in there. Making it a per-user setting has the advantage over modifying things in /etc/ that if you back up your home directory, wipe your machine, re-install it and then copy your home directory back, you still have that setting.

This article, http://www.joshstaiger.org/archives/...rofile_vs.html amongst many others explains when .bashrc is parsed and when .bash_profile is parsed.


All times are GMT -5. The time now is 08:43 PM.