LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
LinkBack Search this Thread
Old 05-17-2004, 11:09 PM   #1
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 183

Rep: Reputation: 31
Slack 9.1 won't read /etc/bashrc


Hello.

I finally got my Slackware working to almost 90% of what I want however there is one key thing that really bugs the heck out of me.

I created a global bashrc file: /etc/bashrc. When I log in as myself, this file seems to be read. However if I then become root with 'su' this file is ignored and all of my aliases don't work.
I have to type 'source /etc/bashrc' each time.

Does anyone know what the problem is?
 
Old 05-17-2004, 11:21 PM   #2
major.tom
Member
 
Registered: Jun 2003
Location: Canada
Distribution: Slackware (current); Gentoo (newbie)
Posts: 141

Rep: Reputation: 15
I'm not an expert, but the man page doesn't mantion a file called /etc/bashrc. It says it uses /etc/profile. And I think ~/.bashrc overrides what's in /etc/profile.

Garry
 
Old 05-18-2004, 02:46 AM   #3
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Rep: Reputation: 32
Here's a workaround I use for /etc/profile which I mentioned in another thread..............should work for your purposes, too, with /etc/bashrc

http://www.linuxquestions.org/questi...176#post939176

 
Old 05-18-2004, 01:52 PM   #4
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 51
Code:
cat > ~/.bashrc << "EOF"
if [ -f "/etc/bashrc" ] ; then
        source /etc/bashrc
fi
EOF

Last edited by jong357; 05-18-2004 at 02:35 PM.
 
Old 05-18-2004, 01:56 PM   #5
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 183

Original Poster
Rep: Reputation: 31
Thanks jong357. um.. forgive my ignorance but what does this code do?
I get the jist of it but what is the 'cat > ~/.bashrc << "EOF" ' part do?
And where do I put this script to make it take effect?
 
Old 05-18-2004, 02:01 PM   #6
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 51
Just copy/paste all of that into a terminal at once... Sorry... They are multiple commands

It's creating a ~/.bashrc via the terminal... So it will over ride any existing .bashrc you may have. This file is just telling bash to source /etc/bashrc... Same thing geekster was talking about only script style...

Last edited by jong357; 05-18-2004 at 02:04 PM.
 
Old 05-18-2004, 02:04 PM   #7
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 183

Original Poster
Rep: Reputation: 31
What will this do exactly?

I'm sorry about my ignorance. I don't do much bash scripting.
 
Old 05-18-2004, 02:04 PM   #8
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 51
I was editing while you were posting...
 
Old 05-18-2004, 02:09 PM   #9
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 183

Original Poster
Rep: Reputation: 31
So if I copy/paste this into my /etc/profile file it should be read everytime for every user right?
 
Old 05-18-2004, 02:11 PM   #10
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 51
No..... Copy all of that and then just paste it into a terminal. Then it will create a file in your home directory (whatever user you are logged in as) called .bashrc

The new file will contain this:

if [ -f "/etc/bashrc" ] ; then
source /etc/bashrc
fi

You could just open up Kedit or Gedit and paste those 3 lines into it and save it as .bashrc

Same thing.... I just like doing stuff from the prompt
 
Old 05-18-2004, 02:31 PM   #11
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 48
If you are just using "su" to move over into rootville, it doesn't read bashrc or profile or anything. If you use "su -" to actually log on (as it were) as root, then it reads all of your config files and your aliases will be working normally!

-- Poetics
 
Old 05-18-2004, 03:13 PM   #12
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Rep: Reputation: 32
The 'source /etc/profile' command should go into /root/.bashrc so when you 'su' to root it will reread the /etc/profile.............just putting it into a normal user's .bashrc file will not work if you ar su'ing to root, only if you are su'ing to that user........

And nice tip Poetics.............I never knew the difference between 'su' and 'su -'. ................But I can't seem to run a gui app from the command line when I 'su -' to root. even with the needed entries for the 'xhost ...' command.........I think I'll keep the old way of doing it...
 
Old 05-18-2004, 08:28 PM   #13
Nichole_knc
Member
 
Registered: Mar 2004
Location: Georgia
Distribution: SlackWare 10.1+, FreeBSD 4.4-5.2, Amiga 1.3,2.1,3.1, Windors XP Pro (makes a fair answering machine)
Posts: 287

Rep: Reputation: 30
the bashrc profile contains the correct script to keep the settings of the script for going su
It is located near the end
You can edit this file and put it in your ~/ as .bashrc with the su/root section and it will retain your settings across the su/root change
 
Old 05-18-2004, 11:11 PM   #14
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 51
Quote:
The 'source /etc/profile' command should go into /root/.bashrc so when you 'su' to root it will reread the /etc/profile
You guys are confusing me... He wants his global bashrc file to be read. I don't really know what he wants kept over an su so apples and oranges I suppose... He said "aliases"... As I'm sure we have all seen a thousand times...

Quote:
# System wide aliases and functions should go into /etc/bashrc
# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc
I never use a user account so I guess I'm just not familiar with the behavior of the shell in those conditions... I find my self suing every 2 seconds so I decided to run with a uid0 a long time ago.... I suppose it doesn't matter where you put it, as long as it activates the function you want.

Last edited by jong357; 05-18-2004 at 11:23 PM.
 
Old 05-19-2004, 12:19 AM   #15
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Rep: Reputation: 32
Quote:
Originally posted by jong357
... He wants his global bashrc file to be read....
The same thing applies...............if he su's to root, then use whichever command is needed or wanted, 'source /etc/profile' or 'source /etc/bashrc'................The way I understood your instructions is to put the lines in ~/.bashrc, or the user's home directory:
Quote:
Then it will create a file in your home directory (whatever user you are logged in as) called .bashrc
I just wanted to clarify that if su'ing to root, those lines should go in root's .bashrc file in root's home directory to reread the global files in /etc.........just putting them into a user's .bashrc in the user's home directory won't help you if su'ing to root...............
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Slack have an equivalent to .bashrc? thorney Slackware 7 11-26-2005 01:08 PM
KDE 3.4 - Konsole doesn't read ~/.bashrc merchtemeagle Linux - Software 7 04-27-2005 12:01 PM
Slack and .bashrc Tinkster Slackware 16 05-10-2004 11:40 PM
bashrc not read by root, can't open display SerfurJ Slackware 6 12-05-2003 10:54 PM
How to read PDF in Slack CodeWarrior Slackware 8 07-26-2003 04:49 PM


All times are GMT -5. The time now is 06:52 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration