LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   NASA Newbie - /bin/tcsh User ported to Linux - How to set PATH (https://www.linuxquestions.org/questions/linux-newbie-8/nasa-newbie-bin-tcsh-user-ported-to-linux-how-to-set-path-679412/)

wstaylor711 10-27-2008 04:31 PM

NASA Newbie - /bin/tcsh User ported to Linux - How to set PATH
 
Greetings,

We've just been herded off SGI Main Frames to Altix/Linux. This user has favored /bin/tcsh and would like to stay with it in Linux. Question: How is the PATH variable set? UNIX is, of course, .login .cshrc, etc.. I haven't got a clue how to append to the default PATH. Any takers?

BrianK 10-27-2008 04:56 PM

Quote:

Originally Posted by wstaylor711 (Post 3323442)
Greetings,

We've just been herded off SGI Main Frames to Altix/Linux. This user has favored /bin/tcsh and would like to stay with it in Linux. Question: How is the PATH variable set? UNIX is, of course, .login .cshrc, etc.. I haven't got a clue how to append to the default PATH. Any takers?

If you want per-user control, just put a .tcshrc in the user's home dir.

edited to add:
and in tcshrc, to add to the path, you do something like:
Code:

setenv PATH ${PATH}:/other/path:/one/more:${HOME}/bin
note the lack of '=' like in a bash export.

pixellany 10-27-2008 04:58 PM

Welcome to LQ!!

Where in NASA?? (I'm at an obscure quasi-center in Pasadena...;))

The PATH variable is set/modified in one or more of the init scripts---which one(s) depends on the distribution. I'm not sure how it is affected by your choice of shell.

In BASH at least, you append to the PATH thusly:

export PATH=$PATH:/etc/X11

(In this example, I added /etc/X11 to my PATH)

wstaylor711 10-27-2008 05:18 PM

Many Thanks to BrianK and pixellany for good info on how to append to the PATH environment variable. BrianK's advice hit the head spot on and pixellany's references were much appreciated.

wstaylor711
(MSFC/EV31)

i92guboj 10-27-2008 05:41 PM

The info here from pixellany is a bit inaccurate.

The init files for the shell depends only on the shell, and not the distro. Bash reads a number of files, tcsh reads others. The man page for either of them will tell you the files that are involved. I don't think that unix vs. linux is a factor here at all, unless I misunderstood something.

pixellany 10-28-2008 05:18 AM

Quote:

Originally Posted by i92guboj (Post 3323493)
The info here from pixellany is a bit inaccurate.

The init files for the shell depends only on the shell, and not the distro. Bash reads a number of files, tcsh reads others. The man page for either of them will tell you the files that are involved. I don't think that unix vs. linux is a factor here at all, unless I misunderstood something.

Most distros I have used default to BASH, and there are still big differences in the init process. I don't doubt that the choice of shell introduces even more differences.

i92guboj 10-28-2008 10:25 AM

Quote:

Originally Posted by pixellany (Post 3323856)
Most distros I have used default to BASH, and there are still big differences in the init process. I don't doubt that the choice of shell introduces even more differences.

Well, there are two separate issues here.

Most init systems depends on bash (or any other shell) to do some tasks. That means that some of the init scripts will be shell code, so yes: in that sense, some of the scripts that will be sourced at startup depends on the distro.

But my point was that these are not shell initialization files. That they are bash code is a mere coincidence, and a design decision of the people who designed the init system of that distro.

The bash initialization files are very well documented on the bash man pages, and having one or another distro doesn't change that (unless the distro maintainer patches bash, of course). They are always the same files, and they are always read on the same very order, and depending on whether the shell is or not a login shell one or another file is used. It's all in the man page, "INVOCATION" section.

And I guess that the same is true for tcsh, ksh or whatever shell.

Out of curiosity, I googled for the tcsh man page and on a first sight you can see a section called "Startup and shutdown", there you can see:

Quote:

A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login. It then executes commands from files in the user's home directory: first ~/.tcshrc (+) or, if ~/.tcshrc is not found, ~/.cshrc, then ~/.history (or the value of the histfile shell variable), then ~/.login, and finally ~/.cshdirs (or the value of the dirsfile shell variable) (+). The shell may read /etc/csh.login before instead of after /etc/csh.cshrc, and ~/.login before instead of after ~/.tcshrc or ~/.cshrc and ~/.history, if so compiled; see the version shell variable. (+)

Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on startup.
As you see, it's something only relevant to tcsh, a distro-agnostic thing. And it will work the same on solaris or bsd by that matter as long as tcsh compiles and is usable under them.

wstaylor711 10-30-2008 02:05 PM

Many thanks pixellany and i92juboj for further responses to my initial query. I have been able to append the the system set PATH variable based on BrianK's input and have reviewed these recent additions with further interest. What a forum! You guys are great! I am pleased to have my understanding challenged and my noggin expanded.


All times are GMT -5. The time now is 12:20 PM.