Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 597  / 2 Years ago, tue, february 15, 2022, 8:19:02

Recent instructional video I was watching said to put your export PATH="$PATH..." statement in your .profile and after sourcing manually in the terminal to append ". ~/.profile" to your .bashrc file as well. However, when I do this it messes up my terminal when I open a new tab rather than allows me to access the bin from the path.


Did this behavior change? If so, where is the correct place to source my profile so that opening a new tab or terminal window gives access to the same commands/executables in the bin folder I am referencing?


Mainly need guidance on ensuring that changes to .profile did not need to be referenced elsewhere. This was understood and picked up by the person who answered my question - marked as answer below.


Edited for clarity and to fix a typo.


More From » bash

 Answers
0

Ubuntu has a non-standard setup it has inherited from Debian and its .bashrc file is sourced by .profile:


$ grep -A1 bashrc /etc/skel/.profile 
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi

So if you then also source .profile from ~/.bashrc you get into an infinite loop, which will break your shell.


The right way to add a new directory to your $PATH is to edit ~/.profile. The file is sourced every time you start a new login shell and, on Ubuntu systems, is also sourced when you log in graphically. After modifying ~/.profile to add something to the $PATH, the change will take effect next time you log in. So instead of making ~/.bashrc source ~/.profile, just logout and log back in again and your changes will be there.


[#744] Tuesday, February 15, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
entmpy

Total Points: 52
Total Questions: 112
Total Answers: 113

Location: Marshall Islands
Member since Tue, Sep 21, 2021
3 Years ago
entmpy questions
;