0

I want to know if there is any guidance I should be following somewhere (maybe from a man page or something) regarding creation of a ~/.bash_profile. By default Ubuntu 18.04 doesn't have one, it just has a .profile file. As I understand it, .profile should just be executing ~/.bashrc. Thus my assumption is that I just need to add a line at the end of my ~.bash_profile to execute ~/.bashrc ; something like:

[[ -f ~/.bashrc ]] && . ~/.bashrc

The reason I ask is because if I create this file, then my .profile file will not be called, so I just need to make sure I'm doing it right.

Second part of my question is, am I correct in understanding ~/.bash_profile should only be invoked ONCE during my login, and then that's it (i.e. sub-sequent interactive shells will just invoke only /etc/bash.bashrc followed by ~/.bashrc?

NotTheDr01ds
  • 17,888
john smith
  • 3,033

1 Answers1

0

I had similar questions about six months ago and got some excellent guidance. Please refer to my question and its answers.

I ended up putting in ~/.bashrc everything I needed for working at the command line and putting everything else in ~/.profile. I source ~/.bashrc at the top of ~/.profile and ~/.bash_profile.

If you'd like to look over the current incarnation of my dotfiles, such as they are, you're welcome to do so. They're reasonably well-organized (I think) and well-commented.

terdon
  • 100,812
MDeBusk
  • 1,175
  • 2
  • 8
  • 21
  • 1
    Why would you keep a .bash_profile file only to have it source .profile? .profile will always be sourced by any shell instance that would read .bash_profile, unless .bash_profile exists. So you are creating a file that isn't needed only to have it do exactly what would happen if you hadn't created the file in the first place. Just delete your .bash_profile and you will be in the same situation you are in now. – terdon Dec 05 '22 at 12:41
  • @terdon I have no explanation for that. My best guess is that I did it before I understood fully what was going on. As it's not drawn any attention to itself, I've left it alone. I'll consider removing it. – MDeBusk Dec 05 '22 at 15:43