LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-21-2004, 10:33 PM   #1
ngan_yine
Member
 
Registered: Aug 2003
Distribution: Slackware 10.1
Posts: 113

Rep: Reputation: 15
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
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-21-2004, 10:34 PM   #2
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
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

Last edited by gbonvehi; 09-22-2004 at 12:21 AM.
 
Old 09-22-2004, 12:18 AM   #3
Sadrul
LQ Newbie
 
Registered: Mar 2004
Distribution: Slackware 10.0 (K: 2.4.26)
Posts: 13

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

-- Adil
 
Old 09-22-2004, 12:41 AM   #4
theonebeyond
Member
 
Registered: Aug 2004
Location: Germany
Distribution: Slackware 10.0
Posts: 258

Rep: Reputation: 30
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
 
Old 09-22-2004, 12:47 AM   #5
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Actually i realized after reading what Sadrul said, that my bash_profile loads bashrc for me, sorry ngan_yine, do what they said
 
Old 09-22-2004, 02:06 AM   #6
ngan_yine
Member
 
Registered: Aug 2003
Distribution: Slackware 10.1
Posts: 113

Original Poster
Rep: Reputation: 15
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.
 
Old 09-22-2004, 03:10 AM   #7
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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
 
2 members found this post helpful.
Old 09-22-2004, 04:52 AM   #8
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 881

Rep: Reputation: 130Reputation: 130
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
 
Old 01-14-2009, 02:56 PM   #9
dikiy
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
nice help all...
 
Old 09-11-2009, 01:48 PM   #10
caduqued
Member
 
Registered: Apr 2008
Location: Coventry, United Kingdom
Distribution: Slackware64, Slackware64 13.37, linuxslackware
Posts: 83

Rep: Reputation: 25
Quote:
Originally Posted by Cedrik View Post
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....
 
Old 12-11-2019, 05:50 AM   #11
Nick-us
Member
 
Registered: Feb 2019
Distribution: Slackware64-Current
Posts: 65

Rep: Reputation: 8
Question

Quote:
Originally Posted by DaneM View Post
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
DaneM If you read this and can answer...
You state in your reply to the Order that the files are read.
But it is not being read on my system at all. /etc/bashrc
For the system it's as if the file didn't exist
If you can explain to me how to make the system read this file in the order you mentioned I appreciate it!
Thanks.
 
Old 12-11-2019, 06:46 AM   #12
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Sadrul View Post
you can create .bashrc, but i don't think it will work. rather create/edit the .bash_profile file.
They are two different things:
.bashrc is for shell's that are NOT started as a login shell for that user ID, while
.bash_profile works only for shell's that are.
In some distributions they've setup things that login shell's will execute .bashrc too, but that is NOT the case in Slackware.
Of course, you can do that yourself, by including
Code:
test -r ~/.bashrc && . ~/.bashrc
as the first line of your .bash_profile (or .profile or .bash_login):
Quote:
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, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
(from the bash man page), and
Quote:
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
so normally it is either/or which of these files will be used.
 
1 members found this post helpful.
Old 12-11-2019, 09:50 AM   #13
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
Quote:
Originally Posted by Nick-us View Post
DaneM If you read this and can answer...
You state in your reply to the Order that the files are read.
But it is not being read on my system at all. /etc/bashrc
For the system it's as if the file didn't exist
If you can explain to me how to make the system read this file in the order you mentioned I appreciate it!
Thanks.
[Rant]DaneM last posted to this thread FIFTEEN YEARS AGO. In future, please check the dates on the threads that come up in a search to avoid necroposting.[/Rant]
Anyway, on my system, .bash_profile contains:
Code:
$ cat .bash_profile
# ~/.bash_profile
#
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
The first lines of .bashrc are:
Code:
$ cat .bashrc 
# ~/.bashrc
#
# Source system-wide aliases and functions
if [ -f /etc/bashrc ]; then
source /etc/bashrc
fi
-- snip --
This results in .bashrc & /etc/bashrc running every time bash is started for my user. ~/bashrc contains additional settings for the individual user & /etc/bashrc is sourced by all users.

Last edited by TSquaredF; 12-11-2019 at 09:51 AM.
 
  


Reply

Tags
bashrc, configuration, slack


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Homework... Cant find .bashrc maravillasc Linux - Newbie 11 10-17-2005 09:39 PM
making alias, can't find .bashrc file djgerbavore Slackware 10 07-23-2004 08:23 AM
where could i find the file bashrc Paxmaster Linux - Software 4 07-15-2004 01:47 PM
Is this a valid command? find ./ -name bash.bashrc | cat davidas Linux - Newbie 11 04-06-2004 02:16 AM
HELP !!!can't find my .bashrc deadhead Slackware 4 11-03-2003 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration