Verifying file responsible for $PATH statement regardless of distribution
Hi all. I wouldn't consider myself a newbie per se, but I figured this is probably the best forum to request assistance pertaining to my question. I work on several different varieties of *nix at work. Something I've been having issues contending with is, from the bottom up, how to know (as the regular user) which file in the home directory is responsible for setting the $PATH. Also, knowing whether you're going to have to create the file if it doesn't yet exist. I'm requesting a more in-depth perspective on this so that I can lift up the hood, so to speak, and not ever have to wonder how a system comes up with issuing the correct files for users created. I understand how init kicks off all other subsequent processes and how /etc/profile works. But, I'm having problems reading through the different scripts to understand how variables are set in motion. I use set and env when I want to get "the lay of the land" so to speak. But, to my dismay, there's nothing within either of these commands' output that tells me which files are responsible for defining the current $PATH set for regular users. This seems to be different depending on distributions and, in some cases, it seems like one has to actually create the file from scratch before the system will start using the requested PATH. Any/all help would be hugely appreciated.
Thanks, Loadedmind |
Take a look at /proc/self/environ
Things like environmental variables are stored in RAM. /proc gives you access to these data stuctures. |
Well, there's the hidden files like
.bashrc, .bash_profile for bash, but other shells use other named files eg ksh uses .kshrc, .profile and so on. Knowing what your current shell is tells you where to look. |
RE
Thanks for the info all! Much appreciated. For the latter reply, it seems that the files used by the bash shell seem to vary from system to system. Is this not the case for you? Have you seen the files from bash on Solaris compared to files from linux? They don't seem to have the same functionality/files created.
Thanks again, so much, Loadedmind |
The filenames are (usually) std (per shell) ime, but they don't have to be there.
You'll need to research this a bit. If I'm not sure I just do grep <username> /etc/passwd to get the login shell, then echo $SHELL to confirm I've actually got that shell, then ls -a in the user's home dir, to list all hidden files. I'll also cat /etc/profile You can also cat /etc/shells to see which ones are avail. HTH |
RE
Ok, that's what I normally do as well. Thanks for the information. I'd still kind of like to know what script or scripts are responsible for creating the user-specific files that do such things as set the PATH, set PS1/PS1, etc. Normally I just google things like this, but it seems that finding this information seems a bit tricky. If I find more info on this process, I'll be sure and post a reply later.
Thanks again all for your help, Loadedmind |
All the files that are sourced when you start a bash session are detailed in the man page, I bet the same is true for other shells. So, the man pages are the first thing to check. Beware that the rc files that are sourced are not always the same files. It depends on which kind of session are you starting (non-interactive vs. interactive and login vs. non-login sessions).
Keyword "INVOCATION" on the bash man page. This included any init files that are shell specific under /etc (like /etc/profile or /etc/bash/*) and all the dot files that reside on the user's home. You should also look into /etc/skel, because those files are copied when creating new user accounts, so, that's the place where you should put anything that you want to be by default on the home of every newly created user. |
And just to reinforce, relative to your OP, its really shell dependent more than distro dependent, sort of.
That's the 'beauty' of variety. Having worked on Solaris, HP-UX and various Linuxes I know where you're coming from. ;) I think this is just one of those things you have to learn, more like vocabulary than grammar, if you get my gist. |
Thanks again to everyone for your insight/wisdom. I really appreciate it. It's folks like you that honestly make me proud to evangelize open source/linux. I know that when I send them into the fray (switching to linux if I think it's a good fit for them), there will be folks like you all to guide them. Sniff... HA! 8^)
|
All times are GMT -5. The time now is 05:45 AM. |