1

I've been adding them to /etc/basrhc, and that works most of the time.

But I noticed that when I su to another user, I lose all my aliases.

It turns out that /etc/bashrc is only loaded when the terminal is opened, not on login. And it seems that /etc/profile is loaded on login. So, is that where I should really have put all those aliases?

  • You should be using shell functions, not aliases. Aliases are less featureful, more brittle, and offer no advantages over shell functions. – tripleee Mar 6 '15 at 12:41
2

You should put them in /etc/profile.d/buttles_aliases.sh

The /etc/profile file probably contains this code:

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

Unfortunate lack of quotes, so don't put a space in your filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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