SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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?
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...
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
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!
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...
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:
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
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.
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...............
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.