Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i was taught that /etc/profile was global for environmental variables and settings...and ~/.profile was specific to the user...
and that bash.rc and ~/.bash.rc was for aliases and functions...i was trying to setup a permanent alias in my profile to a common ssh command and read that it should be going into .profile??? is it really not strict or just a rule of thumb?
Historically and standards-wise local additions should go to /usr/local and personal changes to ~/. The reason for that is that when upgrading a whole system these changes don't get undone, reverted or otherwise lost. Given that functions, aliases and commands that are used system-wide could be in /etc/profile.d/* but personal ones should be in ~/.bash_profile or ~/.bashrc. As far as "strictness" is concerned it depends how you look at it: casual users may think of it as "no fun" but others really don't want each system they need to work on to show a difference in behaviour that might potentially bite them...
sigint-ninja, keep in mind that other shells e.g. tcsh incorporate different syntax than bash therefore be careful about your general profile scripts and use conditions when required
for ssh customs you may be also interested in the Host directive of ssh_config
personally I create custom commands in /usr/local/bin more frequently than shell aliases because they are much more flexible
# /etc/profile.d/80-bashrc.sh #########################################
#
# Run user's ~/.bashrc file if shell is bash, and interactive:
#
if [ -n "$BASH" ] && [ -z "$POSIXLY_CORRECT" ] ; then
case $- in
*i* ) # Interactive shell
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
;;
esac
fi
########################################################################
It's not appropriate to run ~/.bashrc for non-interactive shells, shells other than bash, or for bash when running as /bin/sh (POSIXLY_CORRECT).
If you want to do it on a user by user basis rather than system wide you can put it in the users ~/.bash_profile instead of /etc/profile or a member of profile.d.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.