Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set up aliases in /etc/profile.d/ for each login shell. But if I run, I can't use that alias. How can I set alias even for subshells or child processes ?


alias rmvr='rm -rv';
alias cprv='cp -rv';
alias mvrv='mv -rv';
share|improve this question
up vote 9 down vote accepted

Aliases are not inherited. That's why they are traditionally set in bashrc and not profile. Source your from your .bashrc or the system-wide one instead.

share|improve this answer
By inhereted, you mean that for instance exported variables are inherited and the rest is not ? – lisak Aug 5 '11 at 16:03
I don't think that .bashrc helps... If you use that alias then in a subshell, it doesn't know it – lisak Aug 5 '11 at 16:06
bashrc is read for all interactive non-login shells which is why this should work since most shells you start up are interactive non-login shells, and aliases do work in subshells with () – jw013 Aug 5 '11 at 16:12
I didn't know about aliasName() invocation, thank you – lisak Aug 5 '11 at 16:18
Just to be clear, what I meant was in bash, alias foo='echo foobar', enter, (foo) outputs foobar. – jw013 Aug 5 '11 at 16:21

It is because /etc/profile.d/ is used only by interactive login shell. However, /etc/bash.bashrc is used by interactive non-login shell.

As I usually do set some global aliases for system, I have started to create /etc/bashrc.d where I can drop a file with some global aliases:

    HAVE_BASHRC_D=`cat /etc/bash.bashrc | grep -F '/etc/bashrc.d' | wc -l`

    if [ ! -d /etc/bashrc.d ]; then
            mkdir -p /etc/bashrc.d
    if [ "$HAVE_BASHRC_D" == "0" ]; then
        echo "Setting up bash aliases"
            (cat <<-'EOF'
                                    if [ -d /etc/bashrc.d ]; then
                                      for i in /etc/bashrc.d/*.sh; do
                                        if [ -r $i ]; then
                                          . $i
                                      unset i
            ) >> /etc/bash.bashrc

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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