help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to figure out what files has been loaded by bash?


From: Peng Yu
Subject: Re: [Help-bash] How to figure out what files has been loaded by bash?
Date: Sat, 7 Feb 2015 18:01:31 -0600

On Sun, Jan 4, 2015 at 12:51 PM, Bob Proulx <address@hidden> wrote:
> Peng Yu wrote:
>> I try to login to an linux account (with bash as the login shell)? But
>> it somehow hangs before getting to loading .bashrc file (as I put an
>> echo statement in the first line of .bashrc but nothing is printed to
>> the screen). Is there a way debug what files has been loaded in the
>> login process so that I can figure how what causes the problem?
>
> A useful debug technique is:
>
>   ssh -t localhost bash -ix

I tried the above command. I only see the login banner (on ubuntu) and
then entered the password. Then it hangs. Does it mean something is
wrong before bash is called?

> That will trace every command executed at login time.
>
> The bash documentation includes an extensive section describing what
> files are sourced.  Unfortunately due to legacy shell compatibility it
> isn't a completely simple process.
>
>        When bash is invoked as an interactive login shell, or as a
>        non-interactive shell with the --login option, it first reads
>        and executes commands from the file /etc/profile, 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.
>
> Note that .bashrc is NOT sourced at login time.  The ~/.bash_profile
> et al files are sourced at login time.  In your ~/.bash_profile or
> ~/.profile include a statement to source the ~/.bashrc file.
>
> For example I have this in my ~/.profile and share it among bash, ksh,
> zsh, and sh.  All of those read ~/.profile.
>
>   export LANG=en_US.UTF-8
>   export LC_COLLATE=C
>   PATH=$HOME/bin:$PATH
>   if [ -n "$BASH_VERSION" ]; then
>     . "$HOME/.bashrc"
>   fi
>
> Obviously if you only care about bash then that can be simplified.
> But I am always encouraging generality. :-)
>
>   export LANG=en_US.UTF-8
>   export LC_COLLATE=C
>   PATH=$HOME/bin:$PATH
>   . "$HOME/.bashrc"
>
> Bob



-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]