old-www/HOWTO/Path-6.html

81 lines
2.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>PATH HOWTO: Shells</TITLE>
<LINK HREF="Path-7.html" REL=next>
<LINK HREF="Path-5.html" REL=previous>
<LINK HREF="Path.html#toc6" REL=contents>
</HEAD>
<BODY>
<A HREF="Path-7.html">Next</A>
<A HREF="Path-5.html">Previous</A>
<A HREF="Path.html#toc6">Contents</A>
<HR>
<H2><A NAME="s6">6. Shells</A></H2>
<P>
<P>Often user processes are children processes of the shell mentioned in
/etc/passwd for this user. Initialization files of shells often modify
path.
<P>In login, the name of the shell is preceded with '-', for example bash
is called as '-bash'. This signals to the shell that it is a 'login'
shell. In this case, the shell executes the 'login' initialization
files. Otherwise some lighter initialization is performed.
Additionally, the shell checks if it is interactive - are the commands
coming from file or interactive tty. This modifies the shell
initialization so that a non-interactive non-login shell is
initialized very lightly - bash do not execute any initialization file
in this case!
<P>
<P>
<H2><A NAME="ss6.1">6.1 bash</A>
</H2>
<P>
<P>As a normal login shell, bash 'sources' system-wide file /etc/profile,
where the system environment and path can be set for bash
users. However, it is not run when the system interprets the shell as
non-interactive. The most important case is in rsh, where remote
command is executed in the neighboring machine. The /etc/profile is
not run and the path is inherited from rsh daemon.
<P>bash receives command line arguments -login and -i that can be used to
set the shell as a login shell or interactive shell respectively.
<P>The user can overwrite values set in /etc/profile by creating a file
~/.bash_profile, ~/.bash_login or ~/.profile. Note
that just the first one of these is executed thus differing of the
logic of csh initialization. ~/.bash_login is not executed
specially for login shells and if .bash_profile exists, it is not
executed at all!
<P>If bash is used with name sh instead of the name bash, it emulates
original Bourne shell initialization: it sources just files
/etc/profile and ~/.profile and just for login shells.
<P>
<P>
<H2><A NAME="ss6.2">6.2 tcsh</A>
</H2>
<P>
<P>As a login shell tcsh executes the following files in this order:
<P>
<UL>
<LI>/etc/csh.cshrc </LI>
<LI>/etc/csh.login </LI>
<LI>~/.tcshrc</LI>
<LI>~/.cshrc (if .tcshrc is not found)</LI>
<LI>~/.history</LI>
<LI>~/.login</LI>
<LI>~/.cshdirs</LI>
</UL>
<P>tcsh can be compiled to execute login scripts before cshrc scripts. Beware!
<P>Non-interactive shells execute just the *cshrc scripts. *login scripts
can be used to set the path just once in the login.
<P>
<P>
<HR>
<A HREF="Path-7.html">Next</A>
<A HREF="Path-5.html">Previous</A>
<A HREF="Path.html#toc6">Contents</A>
</BODY>
</HTML>