Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Where exactly are environment variables stored? (It would be great if they were stored in a file somewhere, which I could then *permanently* modify.)
I have three books on Linux/Unix and each gives very poor/cursory coverage on this topic.
I notice that environment variables can be changed with a command such as "setenv" in csh, but how can they be modified using bash?
What I really want to fix is my PATH environment variable. I can temporarily amend it in bash using "export PATH=$PATH:/blahblah" but then if I open a new terminal window, I notice my modifications are not saved in any way.
Boy oh boy, all of this is SO needlessly frustrating... *sigh*
The file used to set your personal login environment can vary depending on what you are using.
Most likely the file .bash_profile in your home directory will work. Files starting with a . are considerd hidden files. So in your home directory try doing something like "ls -ld .*" in your home directory. It should reveal plenty of files which you can edit to change your environment.
"it's not in a file, it's in memory.
don't take this the wrong way, but maybe you think the issue is covered very
poorly because you think it's perhaps something else than it actually is..?"
It's interesting that you write that, because that is what I was beginning
to wonder. (The very absence of any mention of any kind of explicit
'initialization file' in the books I have did lead me to wonder.) However...
"in the bashrc files, that will create the path if there isn't one already, as
do other files which are processed before it."
I do understand what you're saying. But, as you wrote, somewhere the path does
have to be created "if there isn't one already." By now, largely out of
curiosity, I have looked pretty hard for the first instance of PATH being set.
But every reference to PATH that I have come across does seem to
include some modification of a previously existing PATH (i.e., $PATH). The
closest I have come to finding the genesis of PATH is /etc/profile. I do think
it has to be set somewhere to begin with. : ) But I haven't found
it quite found it yet.
Btw: You are definitely right about ~many~ files (at various
levels) modifying such environment variables as PATH.
Still, every environment variable does have to be initialized ~somewhere~ by a
file. It has to get into memory somehow. : )
Re: no need for setenv in bash
Yes, I think you are right. What I have just read about bash agrees.
"You might check out the book "Running Linux" from O'Reilly. I think that shell
variables and how to permanently modify them are discussed. I'll have to check
when I get home tonight."
Believe it or not, that is one of my books. (It's a great
book, too, imo. I really like it.) However, beyond the "export" trick I
mentioned earlier, it does not seem to delve too much more into setting
(or the initialization locations of) environment variables, such as PATH, in
bash. (p. 107, Third Edition)
probably the earliest refence to PATH (obviously this is only an example..) is /etc/rc.sysinit. my one there doesn't have a PATH=$PATH thing there, so if it did get done earlier, it'd get nuked.
but... if it wasn't already set there, it really wouldn't matter if it wasn't there, apart from some of the program between rc.sysint and the next setting mightn't work.
my normal PATH is.... EEKKK!!!
so it's a bit of a mess, but the first PATH def of
has been repeated once or twice anyway...
but there's no BIG BANG or such with variables, they don't get defined or anything like in other programming languages... you canalways invent your own, add to others or remove others at a whim.
When I got home last night, I tried the following commands in a terminal window when I booted up Linux:
(not much here)
(gives your path variable and references to /etc/.bashrc)
I think to change your path permanently you will want to edit /etc/.bashrc. I'm not sure if it is /etc/.bashrc or /etc/bashrc. I can't remember exactly what the filename was, but this should be enough for you to find it in /etc.
If you only want to change your $PATH for a single user, then it looks like editing .bash_profile in your user account will be sufficient. Changing anything in /etc will be a global change that affects any new user accounts that are made on the machine.
Check 'Running Linux' pages 90-110 for the important files that are accessed when you boot-up.