~/.bashrc not being applied

Kernels & Hardware, configuring network, installing services

~/.bashrc not being applied

Postby Mintsoft » 2010-01-17 23:06

Hi Guys,

I was wondering if someone might have some ideas about why my user's bashrc is suddenly not being applied.

The actual bashrc itself works fine, it's the same as the root user's. If I sudo su then /root/.bashrc get's applied.
The only thing that happened prior to it ceasing to work was a slipup by accidently performing chmod -R g+rxs to the entire filesystem, however I can't see any reason why that would stop it being applied.

Also, if I run bash --rcfile ~/.bashrc it doesn't work either.

Any thoughts at all would be welcomed graciously!

Thanks
-Rob
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby smallchange » 2010-01-18 02:53

If you start a bash shell as this user and then source the .bashrc file with either
Code: Select all
. ~/.bashrc

or
Code: Select all
source ~/.bashrc

does the file work?

Do you have a statement like this
Code: Select all
# Source .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi


someplace that a login shell will source, such as /etc/profile, ~/.bash_profile or ~/.profile?
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: ~/.bashrc not being applied

Postby milomak » 2010-01-18 07:03

you didn't perhaps do a change to dash?

you can check in /etc/passwd
Laptop (64-bit) - Debian Sid and Win8
Desktop (64-bit) - Debian Sid, ArchLinux, Win8, OpenSUSE 12.3 and Fedora 20
MythTV BE/FE - Debian Stable
MythTV FE - Debian Sid
milomak
 
Posts: 1508
Joined: 2009-06-09 22:20

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-18 08:27

smallchange wrote:If you start a bash shell as this user and then source the .bashrc file with either
Code: Select all
. ~/.bashrc

or
Code: Select all
source ~/.bashrc

does the file work?


Yes, both of those work

smallchange wrote:Do you have a statement like this
Code: Select all
# Source .bashrc if it exists
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi


someplace that a login shell will source, such as /etc/profile, ~/.bash_profile or ~/.profile?


and my ~/.profile contains:
Code: Select all
# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi


milomak wrote:you didn't perhaps do a change to dash?

you can check in /etc/passwd

I'm not entirely sure what you mean, but my /etc/passwd contains:
Code: Select all
rob:x:1000:1000:Rob,,,:/home/rob:/bin/bash

if that's what you meant?

Thanks
-Rob
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby smallchange » 2010-01-18 15:46

The /bin/bash at the end means that your shell is bash. Does a ~/.bash_profile exist? If so .profile will not be sourced. Does this happen when you login at a virtual terminal?
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-18 16:18

smallchange wrote:The /bin/bash at the end means that your shell is bash. Does a ~/.bash_profile exist? If so .profile will not be sourced. Does this happen when you login at a virtual terminal?

There's no ~/.bash_profile, and the terminal appears exactly the same logging in over ssh and physically at the machine (i.e. no bashrc).

Thanks
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby smallchange » 2010-01-18 18:03

I was more interested in the difference between something like a gnome-terminal and a VT.
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-19 09:04

smallchange wrote:I was more interested in the difference between something like a gnome-terminal and a VT.

Oh right! Sorry, crossed wires there!

I don't have gnome installed, but both xterm and xfce-terminal don't apply the bashrc.

Something I have just noticed though, when I login I get a prompt like:
Code: Select all
-bash-3.2$
however when I run bash again (or xfce-terminal/xterm) it looks like
Code: Select all
bash-3.2$
I can't see any reason why they would differ at all o.0

Thanks
-Rob
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby smallchange » 2010-01-19 14:47

So when you use CTL-ALT-F1 to get to a virtual terminal and login without X in the way does your .bashrc get sourced?
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-19 15:00

smallchange wrote:So when you use CTL-ALT-F1 to get to a virtual terminal and login without X in the way does your .bashrc get sourced?

Nope, not at all; this machine doesn't use a graphical login anyway.

Thanks
-Rob
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby nadir » 2010-01-19 16:11

The actual bashrc itself works fine, it's the same as the root user's.

how come?

post your bashrc's.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.
User avatar
nadir
 
Posts: 5965
Joined: 2009-10-05 22:06
Location: away

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-19 17:14

nadir wrote:
The actual bashrc itself works fine, it's the same as the root user's.

how come?

post your bashrc's.


Because I replaced the root's one with this user's ages ago, however see below:
/home/rob/.bashrc
Code: Select all
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# disable annoying beeps
setterm -blength 0

alias mutt='mutt -f imap://rob@mail'


/root/.bashrc
Code: Select all
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;31m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# disable annoying beeps
setterm -blength 0

alias mutt='mutt -f imap://rob@mail'


Like I said, they're the same and it worked fine up until this weekend.

Thanks
-Rob
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-21 16:10

Solution!

I've stumbled on the solution just now, it turns out that if /bin/bash is chmod g+x then the bashrc doesn't get executed (!?), so chmod -gx /bin/bash fixed it.

Thanks for the help guys!
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Re: ~/.bashrc not being applied

Postby smallchange » 2010-01-21 20:37

That must not be the entire story because my systems all have group execute on /bin/bash and my login shells hit .bash_profile which sources .bashrc.
~ $ll /bin/bash
-rwxr-xr-x 1 root root 792K Jan 2 07:26 /bin/bash
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: ~/.bashrc not being applied

Postby Mintsoft » 2010-01-21 20:41

smallchange wrote:That must not be the entire story because my systems all have group execute on /bin/bash and my login shells hit .bash_profile which sources .bashrc.
~ $ll /bin/bash
-rwxr-xr-x 1 root root 792K Jan 2 07:26 /bin/bash

Sorry, typo there, I meant g+s.

Thanks
Mintsoft
 
Posts: 12
Joined: 2010-01-16 17:20

Next

Return to System configuration

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable