On Sat, Jul 26, 2008 at 9:11 AM, Nuno Magalhces <[EMAIL PROTECTED]>
wrote:
...
> This is my ~/.bashrc (equal for the regular user and root):
>
> # setenv
> export PKG_PATH=ftp://ftp.fmed.uc.pt/pub/OpenBSD/4.3/packages/i386/
> # alias
> alias cl='clear'
> #alias l='ls -lh --time-style=+"[EMAIL PROTECTED]:%M"'
> alias date='date "+%d/%m/%y %T"'
>
> I oughta add #!/path/to/bash here...

(Why?  That line would have no use)


> I ssh to the BSD machine with the regular user (so i figure this is a
> login shell) but my aliases won't work;
> i su to get root and my aliases will work (not login?);
> i su again to the regular user and my aliases will work (no pass
> involved, so this is non-interactive?).

<sigh>  What I wrote in my last message explains/predicts all the
above behavior:

>> Bash is different: a login shell reads a profile startup file (your
>> choice of three different names) and stops there, no $ENV processing,
>> while an interactive shell reads ~/.bashrc.

The shell started by ssh is indeed a login shell, which does *NOT*
read ~/.bashrc.  Thus, no aliases there.  "su user" starts an
interactive shell, which does read the (target user's) ~/.bashrc.

Whether su prompts for a password or not does not affect the mode of
the shell that it starts.  su only starts a non-interactive shell when
invoked with the -c option or with the name of a shell script, both of
which it just passes through to the shell, at which point this part of
my previous email says what happens:

>> A shell that processes a shell script or that was passed the -c option
>> is non-interactive.


> I'm not setting $variables
> here so i'd assume each .bashrc is valid for that session.

I'm not 100% sure what you're trying to say here.  It sounds like you
think bash should *always* parses the .bashrc when starting, but
that's *not true*.


> Also i must
> change to the regular user's home directory before issuing su,
> otherwise i'll get permission denied messages (makes sense).

Right.  By default, su does not change directories before executing
the new shell.  So, if you're currently root, and in ~root (which
isn't executable by other users), and use 'su', the new, non-root
shell will be unable to determine what its current directory is.


Philip Guenther

Reply via email to