LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 05-25-2008, 11:16 PM   #1
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 295
Blog Entries: 3

Rep: Reputation: Disabled
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
 
Old 05-25-2008, 11:44 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Take a look at /proc/self/environ

Things like environmental variables are stored in RAM. /proc gives you access to these data stuctures.
 
Old 05-26-2008, 12:49 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
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.
 
Old 05-27-2008, 09:03 AM   #4
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 295
Blog Entries: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-27-2008, 07:01 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
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
 
Old 05-28-2008, 07:35 AM   #6
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 295
Blog Entries: 3

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-28-2008, 11:43 AM   #7
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,072

Rep: Reputation: 384Reputation: 384Reputation: 384Reputation: 384
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.

Last edited by i92guboj; 05-28-2008 at 11:45 AM.
 
Old 05-28-2008, 07:01 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
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.
 
Old 06-26-2008, 10:11 PM   #9
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 295
Blog Entries: 3

Original Poster
Rep: Reputation: Disabled
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^)
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH statement from file granny Linux - Newbie 8 04-21-2005 12:58 PM
Adding directories to the PATH statement kaplan71 Slackware 2 09-02-2004 03:57 PM
please tell me if my path statement is correct on RH 7.3 ergo_sum Linux - Newbie 9 12-12-2003 11:41 PM
PATH statement editing? cottonmouth Linux - General 2 08-17-2003 08:00 PM
What file hold the PATH statement billkris Linux - General 7 02-11-2003 10:30 PM


All times are GMT -5. The time now is 12:18 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration