3

I'm running RHEL5. I added simple alias command into ~/.bashrc. When I start a new terminal, nothing happens but source ~/.bashrc works so I know the syntax is correct. I also modified/source-tested ~/.bash_profile but it's not executed on terminal startup either. ~/.bash_login and ~/.profile don't exist on my system.

here is my ~/.bashrc

# .bashrc

# Source global definitions if [ -f /etc/bashrc ]; then
        . /etc/bashrc fi

# User specific aliases and functions
alias hi=hello

And my ~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

closed as off-topic by terdon Sep 12 '14 at 17:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • How do you start a new terminal? If you start it by clicking onto an icon this should be okay as this will start a non-login shell. Are you sure you are inside a bash shell? Type echo $SHELL, the system's response should be /bin/bash. On linuxintro.org/wiki/Boot_process#user_starts_a_shell I describe that the process sourcing .bashrc is login. Can you just call bash and see if .bashrc is being executed? – Thorsten Staerk Sep 12 '14 at 11:15
  • 1
    That should be .bash_profile, not .bash_profiles. Was that a typo? – terdon Sep 12 '14 at 12:19
  • Related: unix.stackexchange.com/questions/88106/… – AntonioK Sep 12 '14 at 13:56
  • @terdon Yes it's a typo, fixed. – user49888 Sep 12 '14 at 17:02
  • Thanks. Now, please confirm that 1) you're running bash and not another shell and 2) your terminal is not configured to start login shells. If neither .bashrc nor .bash_profile is being sourced, you're likely not running bash at all. – terdon Sep 12 '14 at 17:05
2

~/.bashrc is only executed for non-login shells, check your terminal settings:
Edit -> Profile Preferences -> Title and Command -> "Run command as a login shell

The usual ~/.profile loads ~/.bashrc if it is available, if - assuming $BASH_VERSION is present in your environment.

Keep in mind though that ~/.profile is ignored if if there's ~/.bash_profile or ~/.bash_login in your home and that, as a result of it being ignored, ~/.bashrc isn't sourced, too.

  • You're probably right about the OP starting login shells but note that the "usual" .profile does not source .bashrc. It does on some systems but it is not the case everywhere and is not true on the SuSe system I just checked. Your last line is wrong, .profile itself is ignored if either .bash_profile or .bash_login exist, this has nothing to do with whether or not .bashrc is read by .profile. – terdon Sep 12 '14 at 12:15
  • @terdon Yes, that's what I meant - I'll try to reprhase it in an edit. – Jan Sep 12 '14 at 12:55
  • In recent-ish Debian default files, .profile checks if it's running Bash, and if so, loads .bashrc. In the glacial terms of Debian development, this is a relatively recent arrangement, and certainly not generalizable to other distributions. Perhaps Red Hat had this for a longer time. – tripleee Jan 18 '18 at 6:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.