LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   I can't find .bashrc in slackware (http://www.linuxquestions.org/questions/slackware-14/i-cant-find-bashrc-in-slackware-233632/)

ngan_yine 09-21-2004 10:33 PM

I can't find .bashrc in slackware
 
Hi guy

I know this sound very stupid but I got to ask because I am out of idea ,I use to be a mandrake user and suddenly I decide to change to slackware and I like what I found.
But I had been finding .bashrc in slackware and I can't seem to find it ,I try all the data base search command but there is just no .bashrc .So could any of you guy tell me what to do if I want to add some vauable to my bash file?

thanks

gbonvehi 09-21-2004 10:34 PM

It isn't created by default, just create it with your favourite editor :)

Btw, it must be created in your home directory. Mine would be: /home/gbon/.bashrc

Sadrul 09-22-2004 12:18 AM

you can create .bashrc, but i don't think it will work. rather create/edit the .bash_profile file.

-- Adil

theonebeyond 09-22-2004 12:41 AM

Yeah... I had the problem too, and as Sadrul said, use .bash_profile for users..

But if I remember right .bashrc works for root (only)

Greetings, Sascha

gbonvehi 09-22-2004 12:47 AM

Actually i realized after reading what Sadrul said, that my bash_profile loads bashrc for me, sorry ngan_yine, do what they said :)

ngan_yine 09-22-2004 02:06 AM

Thanks man
That really help me a lot , as you guys said .bashrc only work for root and not for normal user ,I guess I got to go a long with .bash_profile for my normal user.I was trying to add some enveroment variable PATH to my bash file .In mandrake I can just open the .basrc in /home/~/.bashrc but in slackware the file didn't
didn't exist at all.My experience with linux is still in newbie level but I always thought that bash shell PATH file got to be kept in that .bashrc.I am having a lot of problem with slackware but this one is really worth it.I gave up mandrake and fedore althought it is less painful to operate.

Cedrik 09-22-2004 03:10 AM

In doubt, read man bash ;)

When bash is invoked as an interactive login shell, or as a non-interactive shell
with the --login option, it first reads and executes commands from the file
/etc/profile, After reading that file, it looks for ~/.bash_profile...

When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc

So when you enter in runlevel 3 and then login, bash will read ~/.bash_profile,
but if you startx and then open a new terminal without -ls switch, then bash will read ~/.bashrc...

As gbonvehi said, if you want ~/.bashrc loads no matter if it is at login or when
open a new terminal, just create a ~/.bash_profile like this :

Code:

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

So if there is a ~/.bashrc in your home directory it will be loaded at login or when
open a non-login shell

DaneM 09-22-2004 04:52 AM

Something you might want to note is that BASH loads configuration/init files in roughly this order:

/etc/profile (global settings)
/etc/inputrc (global settings)
/etc/profile.d (global settings)
/etc/bashrc (global settings, but only read if "sourced" from another configuration file -- not created in slackware by default, but very useful for path settings, etc.)
~/.bash_profile (user-specific settings)
~/.bashrc (user-specific settings, but only read if "sourced" from another file, like Cedrik says)
~/.bash_login (user-specific settings to be executed upon login, such as greetings, etc.)

If you would like to apply settings from /etc/bashrc, it's best to put "source /etc/bashrc" at the BEGINNING of ~/.bash_profile or ~/.bashrc . This will load all the global variables from /etc/bashrc but allow your user-specific settings to override them. You can find more indespensible information on BASH and other cool Linux stuff at http://www.tldp.org/guides.html . Good luck with your new Slackware installation!

--Dane

dikiy 01-14-2009 02:56 PM

nice help all...

caduqued 09-11-2009 01:48 PM

Quote:

Originally Posted by Cedrik (Post 1190149)
In doubt, read man bash ;)

When bash is invoked as an interactive login shell, or as a non-interactive shell
with the --login option, it first reads and executes commands from the file
/etc/profile, After reading that file, it looks for ~/.bash_profile...

When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc

So when you enter in runlevel 3 and then login, bash will read ~/.bash_profile,
but if you startx and then open a new terminal without -ls switch, then bash will read ~/.bashrc...

As gbonvehi said, if you want ~/.bashrc loads no matter if it is at login or when
open a new terminal, just create a ~/.bash_profile like this :

Code:

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

So if there is a ~/.bashrc in your home directory it will be loaded at login or when
open a non-login shell

Nice explanation: plain, clear and simple.... ;)


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