Machine# #2
I am want to find out how to properly add ~/.local/bin to PATH.
I need to do this in order to run a program from a bash [Konsole] terminal because the program resides in ~/.local/bin
I have read a couple of articles on ways to do this but am unsure and don’t want to mess anything.
My current PATH is:
So if I want to add this to my PATH permanently I am supposed to open bashrc with an editor{nano??}
and add the following line at the end of it. I note here that when I opened this ~/.bashrc file there was nothing in it.
export PATH="$HOME/bin:$PATH"
What I am not sure of is: Do I just insert this line or do I have to substitute $HOME for .local?
export PATH=".local/bin:$PATH"
Or is there another/better way to do this?
Thank You.
#
# Make path more comfortable
#
# save current path setting, we might want to restore it
ORIG_PATH=$PATH
#
if test -z "$PROFILEREAD" ; then
PATH=/usr/local/bin:/usr/bin:/bin
if test "$HOME" != "/" ; then
for dir in $HOME/bin/$CPU $HOME/bin $HOME/.local/bin/$CPU **$HOME/.local/bin** ; do
test -d $dir && PATH=$dir:$PATH
done
fi
if test "$UID" = 0 ; then
test -d /opt/kde3/sbin && PATH=/opt/kde3/sbin:$PATH
PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
fi
for dir in /usr/X11/bin \
/usr/X11R6/bin \
/var/lib/dosemu \
/usr/games \
/opt/bin \
/opt/kde3/bin \
/opt/kde2/bin \
/opt/kde/bin \
/usr/openwin/bin \
/opt/cross/bin
do
test -d $dir && PATH=$PATH:$dir
done
unset dir
export PATH
fi
Creating $HOME/.local/bin will automatically prepend the directory to PATH on next login:
The main issue with the PATH variable is, it ain’t only used by “bash” – it’s used by every other shell as well plus, some Desktop Environments.
Therefore, do not set the PATH variable in the ~/.bashrc file.
The system-wide setting of the PATH variable is done in the /etc/profile file – if you do not wish to believe me, “grep” for PATH in /etc …
Therefore, simply follow the system-wide method and, set any user specific modifications needed to the PATH variable in the user’s ~/.profile file.
[HR][/HR]Editor to use –
Short answer, any text editor.
Command line – “vim” or, “ex” or, “ed” or, EMACS or, whatever
… - Desktop Environment – simply click on the configuration file – the default text editor will, normally, start and, open the file for editing:
If KDE Plasma then, “Kate”.
If GNOME then, “gedit”.
If something else then, whatever that Desktop Environment has as a default text editor.
[HR][/HR]And, if you want to append you private Path to the PATH variable – as opposed to prepending «as in attaching as a prefix» your private Path to the PATH variable, then, you have to use the following syntax:
export PATH=${PATH}:"$HOME/.local/bin"
[HR][/HR]Why make it complex when, it’s so simple?
Even that thing out of Redmond normally opens text files for editing if, you «double
» click on the file …
If your system is multi-user, i.e., others using system and doing different things, I would add the amended PATH statement to the user ~/.bashrc file rather than the system profile file. Changing PATH in /etc makes it universal fror all users. This could upset executible searches that other users are doing for their searches. Each user has its own ~/.bashrc file that is run upon login for that user or when a user runs “source” command. Put their personal PATH needs in ~/.bashrc.
If it is a single user system, it makes no difference where you put the amended PATH statement.
Hi Tom
There is nothing to do, if the directory exists for $USER, the openSUSE default /etc/profile checks for this directory ~/.local/bin and will add to $PATH.
Jumping on the thread here:
I have done exactly this to my ~/.bashrc (I am the only user) and when I echo $PATH after reboot I get my newly defined path appended twice. How do I append it only once?