Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
~/.bashrc not being applied
~/.bashrc not being applied
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
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
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: ~/.bashrc not being applied
If you start a bash shell as this user and then source the .bashrc file with either
or
does the file work?
Do you have a statement like this
someplace that a login shell will source, such as /etc/profile, ~/.bash_profile or ~/.profile?
Code: Select all
. ~/.bashrc
Code: Select all
source ~/.bashrc
Do you have a statement like this
Code: Select all
# Source .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Re: ~/.bashrc not being applied
you didn't perhaps do a change to dash?
you can check in /etc/passwd
you can check in /etc/passwd
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Re: ~/.bashrc not being applied
Yes, both of those worksmallchange wrote:If you start a bash shell as this user and then source the .bashrc file with eitherorCode: Select all
. ~/.bashrc
does the file work?Code: Select all
source ~/.bashrc
and my ~/.profile contains:smallchange wrote:Do you have a statement like thissomeplace that a login shell will source, such as /etc/profile, ~/.bash_profile or ~/.profile?Code: Select all
# Source .bashrc if it exists if [ -f ~/.bashrc ]; then . ~/.bashrc fi
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
I'm not entirely sure what you mean, but my /etc/passwd contains:milomak wrote:you didn't perhaps do a change to dash?
you can check in /etc/passwd
Code: Select all
rob:x:1000:1000:Rob,,,:/home/rob:/bin/bash
Thanks
-Rob
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: ~/.bashrc not being applied
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?
Re: ~/.bashrc not being applied
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).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?
Thanks
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: ~/.bashrc not being applied
I was more interested in the difference between something like a gnome-terminal and a VT.
Re: ~/.bashrc not being applied
Oh right! Sorry, crossed wires there!smallchange wrote:I was more interested in the difference between something like a gnome-terminal and a VT.
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$
Code: Select all
bash-3.2$
Thanks
-Rob
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: ~/.bashrc not being applied
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?
Re: ~/.bashrc not being applied
Nope, not at all; this machine doesn't use a graphical login anyway.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?
Thanks
-Rob
Re: ~/.bashrc not being applied
how come?The actual bashrc itself works fine, it's the same as the root user's.
post your bashrc's.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.
Re: ~/.bashrc not being applied
Because I replaced the root's one with this user's ages ago, however see below:nadir wrote:how come?The actual bashrc itself works fine, it's the same as the root user's.
post your bashrc's.
/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'
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'
Thanks
-Rob
Re: ~/.bashrc not being applied
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!
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!
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: ~/.bashrc not being applied
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
Re: ~/.bashrc not being applied
Sorry, typo there, I meant g+s.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
Thanks
-
- Posts: 1
- Joined: 2014-02-24 12:16
Re: ~/.bashrc not being applied
Hi,
It's because /etc/bash.bashrc seems not to be sourced in /etc/profile (at least since wheezy) as the variables tested are not in the environment. It's about $PS1 which is tested and $BASH. Both of them don't exsist at that time and the end result is that /etc/bash.bashrc is not sourced. A work around could be to add the lines below in /etc/profile just below the export PATh line at the top.
if [ "$SHELL" = "/bin/bash" ]; then
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
fi
Filip
It's because /etc/bash.bashrc seems not to be sourced in /etc/profile (at least since wheezy) as the variables tested are not in the environment. It's about $PS1 which is tested and $BASH. Both of them don't exsist at that time and the end result is that /etc/bash.bashrc is not sourced. A work around could be to add the lines below in /etc/profile just below the export PATh line at the top.
if [ "$SHELL" = "/bin/bash" ]; then
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
fi
Filip