A
A
appplemac2012-02-16 02:00:51
PowerShell
appplemac, 2012-02-16 02:00:51

Commands from ~/.bashrc not working on login?

Comrades,
I use OpenIndiana, the shell is bash.
I tried to add the path to the binaries I needed to the $PATH variable by adding the following line to ~/.bashrc:

export PATH=/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin:/opt/csw/bin:/opt/csw/gcc4

In theory, with logoff and subsequent login, $PATH should already have the form indicated above, but no - no changes occur.
What could be the problem? Or is it a feature? :)
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry T., 2012-02-16
@appplemac

try adding to ~/.bash_profile

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

A
Alexey Sundukov, 2012-02-16
@alekciy

This is a feature and is described in the mana linux.die.net/man/1/bash
The point is that ~/.bash_profile is read on login, and ~/.bashrc on interactive shell startup. It's very easy to check. We write the line echo 'bash_profile' to ~/.bash_profile , and echo 'bashrc' to ~/.bashrc . Now we log in and start another save shell (i.e. start bash without login):
bash_profile
[[email protected] ~]$ bash
bashrc
[[email protected] ~]$ exit
[[email protected] ~]$

P
Pavel Nazarov, 2012-02-16
@smbd

In general, it's generally accepted to set PATH=$PATH:<your_paths>.
And, there is a bit of an opinion that it is better to store such things in a separate file, ala ~/.profile, and read it, rather than write it directly to bash_*. Why - so that in other shells (well, suddenly you need them) read ~/.profile, and not copy-paste env variables into their .rc files :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question