1

There are many places to set an alias for all users within a Linux system, e.g. /etc/profile, /etc/profile.d/*, /etc/bash.bashrc...

I'm wondering which one is the most proper/correct, in other words, which one is the best in accordance to the conventions of Linux nowadays.

Sorry for my English, I hope I have expressed myself well.

2

1 Answer 1

1

The correct way of placing the aliases depend on when you want to be able to use them.

Bash uses the following start-up files:

                    Login shell              Non-login shell
----------------------------------------------------------------
Interactive shell   /etc/profile             /etc/bash.bashrc
                    ~/.bash_profile          ~/.bashrc
                    ~/.bash_login
                    ~/.profile

/etc/profile sources /etc/bash.bashrc and the files /etc/profile.d/*.sh

So, if you want to use them in a login-shell only (typically if you login via ssh), place them in /etc/profile.d. If you want to use them in a non-login shell (xterm, konsole etc.) too, place them in /etc/bash.bashrc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .