Re: Login script!
*- On 7 Aug, Rudy Broersma wrote about "Login script!"
> Hi,
>
> Is it possible that Linux executes a script file when a user logs on?
> So for example, if user RUDY logs on, it executes the /home/rudy/script
> file, and when ROOT logs on, it executes the /root/script file!
>
> Could anybody please give me some examples?
>
Yes. Each shell has its own files. So look at the man pages for the
shell that you use.
>From the bash man page:
When bash is invoked as an interactive login shell, it
first reads and executes commands from the file /etc/pro
file, if that file exists. After reading that file, it
looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the
first one that exists and is readable. The --noprofile
option may be used when the shell is started to inhibit
this behavior.
When a login shell exits, bash reads and executes commands
from the file ~/.bash_logout, if it exists.
>From the tcsh man page
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 vari
able), 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 vari
able. (+)
Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or
~/.cshrc on startup.
[....]
When a login shell termi
nates it sets the logout shell variable to `normal' or
`automatic' as appropriate, then executes commands from
the files /etc/csh.logout and ~/.logout. The shell may
drop DTR on logout if so compiled; see the version shell
variable.
--
Brian
---------------------------------------------------------------------
Mechanical Engineering servis@purdue.edu
Purdue University http://www.ecn.purdue.edu/~servis
---------------------------------------------------------------------
Reply to: