Google Groepen ondersteunt geen nieuwe Usenet-berichten of -abonnementen meer. Historische content blijft zichtbaar.

Login script!

1 weergave
Naar het eerste ongelezen bericht
Bericht is verwijderd

Oliver Elphick

ongelezen,
7 aug 1999, 03:00:0007-08-1999
aan
"Rudy Broersma" wrote:
>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.

Exactly how it works depends a lot on what your setup is.

1) Not using xdm
a) Shell is sh, bash, ash, ksh or other Bourne-shell derivative:
Every login (except, perhaps, root?) first runs /etc/profile.
Next a file in your home directory is run; which one it is depends on
which shell you are running. Default for Bourne shell is .profile;
for bash it is .bash_profile; other shells may have different
behaviour - read the man page.
b) Shell is csh, tcsh:
.login in your home directory is run

2) Using xdm (log-in in a graphical screen)
If you have a .xsession file in your home directory, it is run; if you
don't, /etc/X11/Xsession is run.


Any of these scripts can run other scripts, without limit.


Different scripts get run if you start a new shell when you are already
logged in.

sh - [nothing]
bash - $HOME/.bash_rc
ksh - [contents of $ENV variable]
csh - $HOME/.cshrc
startx - $HOME/.xinitrc; /usr/X11R6/lib/X11/xinit/xinitrc if $HOME/.xinitrc
does not exist
others may be different again - check the man pages

Some Unix systems require these scripts to be executable.

--
Vote against SPAM: http://www.politik-digital.de/spam/
========================================
Oliver Elphick Oliver....@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"Do not be anxious about anything; but in every thing
by prayer and supplication with thanksgiving let your
requests be made known unto God."
Philippians 4:6

--
Unsubscribe? mail -s unsubscribe debian-us...@lists.debian.org < /dev/null

Michael Stenner

ongelezen,
7 aug 1999, 03:00:0007-08-1999
aan
On Sat, Aug 07, 1999 at 08:44:30PM +0200, Rudy Broersma wrote:
> 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!

your shell takes care of this for you. Note the bash manpage ('man
bash') for the specifics of what it executes and when, but the summary
is this:

if a shell is a login shell (like when you sit down and LOG IN) it
executes:
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile

(note: login shells execute ~/.bash_logout when they exit)

if it is not a login shell (typically, xterms use non-login shells --
as a general, but not universal rule, if you need a password to start
it, it's a login shell), it executes:
~/.bashrc

Other shells have equivalent files, but you'll have to look in the
manpages for the details.

-Michael

--
Michael Stenner Office Phone: 919-660-2513
Duke University, Dept. of Physics mste...@phy.duke.edu
Box 90305, Durham N.C. 27708-0305

Brian Servis

ongelezen,
7 aug 1999, 03:00:0007-08-1999
aan
*- 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 ser...@purdue.edu
Purdue University http://www.ecn.purdue.edu/~servis
---------------------------------------------------------------------

Bob Nielsen

ongelezen,
7 aug 1999, 03:00:0007-08-1999
aan
If you are using the bash shell, the file ~/.bash_profile is read when
logging on.

Bob

On Sat, Aug 07, 1999 at 08:44:30PM +0200, Rudy Broersma wrote:

> 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?
>

> Thanks in advance,
>
> Rudy


>
>
>
>
>
>
> --
> Unsubscribe? mail -s unsubscribe debian-us...@lists.debian.org < /dev/null
>

--
Bob Nielsen Internet: nie...@primenet.com
Tucson, AZ AMPRnet: w6...@w6swe.ampr.org
DM42nh http://www.primenet.com/~nielsen

Paul Miller

ongelezen,
7 aug 1999, 03:00:0007-08-1999
aan
Rudy Broersma wrote:
>
> 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?
>
Yup, when using the BASH shell, it will call the .bash_profile upon an
interactive login or .bashrc for a non-interactive login. You can refer to the
man page for your shell to find out what script file it runs. BTW /etc/profile
is used by most shells as a system wide profile meaning it is read for all
logins.

Hope this helps,
--
Paul Miller
pmi...@jove.acs.unt.edu

Where do all the bits go when the computer is done with them?

0 nieuwe berichten