Page 1 of 1
How to set path in .bash_profile?(solved)
Posted: Thu Jul 20, 2023 10:23 pm
by williwaw
I am tring to export a new path and have it survive across reboots.
I have tried appending a new path to both ~/.bash_profile and ~/.profile.
In the terminal, I can
# source .bash_profile
after making the edit, and it works in the terminal session. When I reboot, the edit exists, but apparenty the file is not read because I have to run
# source .bash_profile in each terminal session
is there a correct place to set my path in puppy?
I am using vanilla 9-3-30
Re: setting path in .bash_profile
Posted: Fri Jul 21, 2023 12:58 am
by geo_c
what about adding it to /root/bashrc?
Just guessing, as I recently added some terminal bookmark code there that creates an alias path in F96.
Re: How to set path in .bash_profile?
Posted: Fri Jul 21, 2023 2:00 am
by williwaw
3.1. Significance of .bash_profile
The .bash_profile file contains commands for setting environment variables. Consequently, future shells inherit these variables.
In an interactive login shell, Bash first looks for the /etc/profile file. If found, Bash reads and executes it in the current shell. As a result, /etc/profile sets up the environment configuration for all users.
Similarly, Bash then checks if .bash_profile exists in the home directory. If it does, then Bash executes .bash_profile in the current shell. Bash then stops looking for other files such as .bash_login and .profile.
If Bash doesn’t find .bash_profile, then it looks for .bash_login and .profile, in that order, and executes the first readable file only.
Let’s look into a sample .bash_profile file. Here we’re setting & exporting the PATH variable:
echo "Bash_profile execution starts.."
PATH=$PATH:$HOME/bin;
export PATH;
echo "Bash_profile execution stops.."
We’ll see the below output right before the command prompt on the interactive login shell:
Bash_profile execution starts..
Bash_profile execution stops..
[dsuser@cygnus ~]$
3.2. Significance of .bashrc
.bashrc contains commands that are specific to the Bash shells. Every interactive non-login shell reads .bashrc first. Normally .bashrc is the best place to add aliases and Bash related functions.
The Bash shell looks for the .bashrc file in the home directory and executes it in the current shell using source.
well reading conventional linux tutorials, I think .bash_profile is what is advised for my use case, but maybe with Puppy, bash is not my login shell, and I didnt log in interactively, so...
I will see how .bashrc works after all, thanks geo
Re: How to set path in .bash_profile?
Posted: Fri Jul 21, 2023 3:23 am
by williwaw
reading here:
https://unix.stackexchange.com/question ... th-to-path
Where to put it
Put the line to modify PATH in ~/.profile, or in ~/.bash_profile or if that's what you have. (If your login shell is zsh and not bash, put it in ~/.zprofile instead.)
The profile file is read by login shells, so it will only take effect the next time you log in. (Some systems configure terminals to read a login shell; in that case you can start a new terminal window, but the setting will take effect only for programs started via a terminal, and how to set PATH for all programs depends on the system.)
Note that ~/.bash_rc is not read by any program, and ~/.bashrc is the configuration file of interactive instances of bash. You should not define environment variables in ~/.bashrc. The right place to define environment variables such as PATH is ~/.profile (or ~/.bash_profile if you don't care about shells other than bash). See What's the difference between them and which one should I use?
Re: How to set path in .bash_profile?
Posted: Fri Jul 21, 2023 4:55 am
by geo_c
I checked in F96 /root/.profile and /etc/profile,
/etc/profile seems to be where the path is set:
Code: Select all
#set variables so everything can be found...
#100622 PKG_CONFIG_PATH is determined in 3builddistro (Woof), written to /etc/profile.d/pkgconfig
#110804 fix double-login when exit from X, allow /etc/profile to complete. see also "echo -n '# '" in /usr/bin/xwin at exit.
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/root/my-applications/bin:/usr/games"
if [ -f /lib64/libc.so.6 ] ; then #slackware64
LD_LIBRARY_PATH="/lib64:/usr/lib64:/root/my-applications/lib:/usr/local/lib"
else
LD_LIBRARY_PATH="/lib:/usr/lib:/root/my-applications/lib:/usr/local/lib"
fi
export PATH LD_LIBRARY_PATH
export GDK_USE_XFT=1 #for gtk...
export OOO_FORCE_DESKTOP="gnome" #Open Office, force ue of GTK...
if [ -d /opt/vc ];then # this is for raspberry pi
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/vc/lib"
[ -d /opt/vc/bin ] && PATH="$PATH:/opt/vc/bin"
fi
ulimit -c 0
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
umask 002
else
umask 022
fi
USER=`id -un`
PS1="# "
LOGNAME=$USER
HISTSIZE=1000
HISTFILE="$HOME/.history"
if [ -f /usr/bin/mp ] ; then
EDITOR=mp
elif [ -f /usr/bin/nano ] ; then
EDITOR=nano
else
EDITOR=vi
fi
PAGER=less
INPUTRC=/etc/inputrc
[ -d /usr/share/terminfo ] && export TERMINFO=/usr/share/terminfo
export PS1 USER LOGNAME HISTSIZE INPUTRC EDITOR PAGER
XFINANSDIR="/root/.xfinans"
export XFINANSDIR
#export XLIB_SKIP_ARGB_VISUALS=1 #rox crashes with DRI modules. solution:
#this line gets edited by chooselocale script...
LANG=en_US.UTF-8
export LANG
[ -f /etc/hostname ] && read HOSTNAME < /etc/hostname
export HOSTNAME
SHELL="/bin/bash"
export SHELL
export MM_RUNASROOT=1 #sylpheed uses metamail which requires this...
BROWSER=/usr/local/bin/defaultbrowser
DEFAULTBROWSER=/usr/local/bin/defaultbrowser
DEFAULTDRAW=/usr/local/bin/defaultdraw
DEFAULTHTMLEDITOR=/usr/local/bin/defaulthtmleditor
DEFAULTMEDIAPLAYER=/usr/local/bin/defaultmediaplayer
DEFAULTPAINT=/usr/local/bin/defaultpaint
DEFAULTSPREADSHEET=/usr/local/bin/defaultspreadsheet
DEFAULTTEXTEDITOR=/usr/local/bin/defaulttexteditor
DEFAULTWORDPROCESSOR=/usr/local/bin/defaultwordprocessor
DEFAULTIMAGEVIEWER=/usr/local/bin/defaultimageviewer
DEFAULTIMAGEEDITOR=/usr/local/bin/defaultimageeditor
export BROWSER DEFAULTBROWSER DEFAULTDRAW DEFAULTHTMLEDITOR DEFAULTMEDIAPLAYER DEFAULTPAINT DEFAULTSPREADSHEET DEFAULTTEXTEDITOR DEFAULTWORDPROCESSOR DEFAULTIMAGEVIEWER DEFAULTIMAGEEDITOR
#freedesktop base directory spec: standards.freedesktop.org/basedir-spec/latest/
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_DIRS=/usr/share:/usr/local/share
export XDG_CONFIG_DIRS=/etc/xdg #v2.14 changed from /usr/etc
export XDG_CACHE_HOME=$HOME/.cache
export XDG_RUNTIME_DIR=/tmp/runtime-${USER}
[ ! -d $XDG_RUNTIME_DIR ] && mkdir -p $XDG_RUNTIME_DIR && chmod 0700 $XDG_RUNTIME_DIR
export HISTFILESIZE=2000
export HISTCONTROL=ignoredups
#w468 'netpbm' utilities need to be told where rgb.txt is...
[ -f /usr/share/X11/rgb.txt ] && export RGBDEF=/usr/share/X11/rgb.txt
export PREFIX='/usr' #convenient to set this i think...
# Append any additional sh scripts found in /etc/profile.d/:
#for profile_script in /etc/profile.d/*.sh ; do
for profile_script in /etc/profile.d/* ; do #w482 any files.
case "$profile_script" in *txt|*.csh) continue ;; esac
. $profile_script
done
unset profile_script
# set environment variables defined in /etc/environment
while read line ; do
case "$line" in \#*) continue ;; esac
export "$line"
done < /etc/environment
alias ls='ls --color=auto'
export LS_COLORS='bd=33:cd=33'
#personal customisation file...
[ -r /etc/profile.local ] && . /etc/profile.local
# fix gtk3 WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
export NO_AT_BRIDGE=1
###END###
Re: How to set path in .bash_profile?
Posted: Fri Jul 21, 2023 5:14 am
by williwaw
I have been looking at that file and trying to figure out how to append the needed directories to make my new path.
I could probally do it manually, but am also working out a redirection command to put into some instructions. I muddled my way down a rabbit hole trying to append my new path statement to a new line.....but in the meantime found this post
https://oldforum.puppylinux.com/viewtopic.php?t=109408
has a solution.
export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/games: /your_ added_ path
then
echo "export PATH=$PATH:" >> /etc/profile.local