Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Debian 11 set path at login ?
Debian 11 set path at login ?
I would like to have my user $PATH expanded once at login to include $HOME/bin.
The following 2 commands do this:
PATH=$PATH:$HOME/bin
export PATH
On some versions of Linux, these 2 commands can be added to a .bash_profile file in the users $HOME directory.
This file would be executed once at login.
Debian 11 does not appear to use this feature.
So what can the user do to have these 2 commands executed automatically (once) at login ?
The following 2 commands do this:
PATH=$PATH:$HOME/bin
export PATH
On some versions of Linux, these 2 commands can be added to a .bash_profile file in the users $HOME directory.
This file would be executed once at login.
Debian 11 does not appear to use this feature.
So what can the user do to have these 2 commands executed automatically (once) at login ?
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
I use Debian 11, AMD64, XFCE. Looking at /home/user/.profile I see the following:
As the comment says, the file is NOT read by bash(1) if ~/.bash_profile or ~/.bash_login exists. Take a look in your /home directory. I would think that this file is there. PATH $HOME/bin should be set..
Code: Select all
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
I am not irrational, I'm just quantum probabilistic.
Re: Debian 11 set path at login ?
Thanks for the idea to check .profile. My .profile is the default version for Debian 11.
No matter what I do, the path is always:
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
If I execute .profile from the command line, then it changes to
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/bright/bin
I changed the .profile so that $HOME/bin appends to the end of the path
So that I know .profile is being executed.
That tells me that the login shell is NOT executing .profile at login.
No matter what I do, the path is always:
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
If I execute .profile from the command line, then it changes to
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/bright/bin
I changed the .profile so that $HOME/bin appends to the end of the path
So that I know .profile is being executed.
That tells me that the login shell is NOT executing .profile at login.
Last edited by gh4rock on 2021-08-29 18:51, edited 1 time in total.
Re: Debian 11 set path at login ?
Removed .bash_profile, no .bash_login file.
I will try a smaller .profile without .bashrc to see if that has any affect.
I will try a smaller .profile without .bashrc to see if that has any affect.
Re: Debian 11 set path at login ?
Mate, if you had .bash_profile, then .profile wasn't being read by bash. No need to remove .bashrc, or change .profile. Just read what is commented in .profile as ticojohn commented.
Re: Debian 11 set path at login ?
I am using Debian 11, Cinnamon desktop.
No .bash_profile.
Tried shorter .profile with only the segment with $HOME/bin.
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
if I execute .profile from the command line, then the $HOME/bin
gets added, otherwise, it does not get added ???
No .bash_profile.
Tried shorter .profile with only the segment with $HOME/bin.
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
if I execute .profile from the command line, then the $HOME/bin
gets added, otherwise, it does not get added ???
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
Okay. I created a $HOME/bin directory, logged out and back in. It is still not in the PATH. So I added this to the end of the .bashrc filegh4rock wrote: ↑2021-08-29 20:18 I am using Debian 11, Cinnamon desktop.
No .bash_profile.
Tried shorter .profile with only the segment with $HOME/bin.
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
if I execute .profile from the command line, then the $HOME/bin
gets added, otherwise, it does not get added ???
Code: Select all
PATH="$HOME/bin:$PATH"
EDIT: And this interesting. In ~/.profile there is a line that says:
Code: Select all
# see /usr/share/doc/bash/examples/startup-files for examples.
I am not irrational, I'm just quantum probabilistic.
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
I believe that there may be a problem with ~/.profile and the inclusion of $HOME/bin in PATH. I made a temporary change to ~/.profile by adding an echo statement in
When I execute ~/.profile and then check the PATH I get this
We can clearly see that the if statement is being executed. And I have a bin folder in $HOME, so why isn't $HOME/bin getting added to PATH? Am I misunderstanding what should be happening? I hope my efforts aren't construed as hijacking this thread. I am just trying to help the OP to figure what is happening and why $HOME/bin isn't getting added as per ~/.profile.
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
echo 1
fi
Code: Select all
john@debian:~$ bash ~/.profile
1
john@debian:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
I am not irrational, I'm just quantum probabilistic.
-
- Posts: 1101
- Joined: 2016-01-07 12:25
- Has thanked: 5 times
- Been thanked: 16 times
Re: Debian 11 set path at login ?
You could try the following which works on my system
I usually copy the code you showed
Code: Select all
. ~/.profile
to my ~/.bashrc file to ensure all terminals have access to my scripts.Code: Select all
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ]; then PATH="$HOME/bin:$PATH" echo 1 fi
Re: Debian 11 set path at login ?
You forgot the export:
Code: Select all
export PATH="$HOME/bin:$PATH"
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
Interesting! I was just reporting exactly what is in ~/.profile as it was apparently generated by the system when a user is created. Does that imply that the system didn't create the correct code? Weird. But I'll take a look. Hopefully the OP sees all this.
Okay. I modified ~/.profile as suggested by @Bloom . Still no joy. I also tried the following, which also didn't work.
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
export $PATH
fi
Code: Select all
PATH="$HOME/bin:$PATH"
I am not irrational, I'm just quantum probabilistic.
Re: Debian 11 set path at login ?
Thanks all for confirming that there is a problem.
To see the bash examples, one must add the bash-doc pkg.
I did some more testing and determined that .bash-login file does append the $HOME/bin to the PATH.
But the results of the "export PATH" do not survive the login sequence, and one is left with the
default path provided by /etc/profile.
Removing .bash_profile and .bash_login so as to work only with .profile has the same result.
Executing .profile from the command line does work, does change the PATH to include $HOME/bin.
But it does NOT appear to be executed during the normal login process.
This means that one must execute a simple script to change the PATH after login.
Trying to run the script automatically via settings... "Startup" does not work either.
To see the bash examples, one must add the bash-doc pkg.
I did some more testing and determined that .bash-login file does append the $HOME/bin to the PATH.
But the results of the "export PATH" do not survive the login sequence, and one is left with the
default path provided by /etc/profile.
Removing .bash_profile and .bash_login so as to work only with .profile has the same result.
Executing .profile from the command line does work, does change the PATH to include $HOME/bin.
But it does NOT appear to be executed during the normal login process.
This means that one must execute a simple script to change the PATH after login.
Trying to run the script automatically via settings... "Startup" does not work either.
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
The only way I've gotten it to work is to addgh4rock wrote: ↑2021-08-30 13:32 Thanks all for confirming that there is a problem.
To see the bash examples, one must add the bash-doc pkg.
I did some more testing and determined that .bash-login file does append the $HOME/bin to the PATH.
But the results of the "export PATH" do not survive the login sequence, and one is left with the
default path provided by /etc/profile.
Removing .bash_profile and .bash_login so as to work only with .profile has the same result.
Executing .profile from the command line does work, does change the PATH to include $HOME/bin.
But it does NOT appear to be executed during the normal login process.
This means that one must execute a simple script to change the PATH after login.
Trying to run the script automatically via settings... "Startup" does not work either.
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ]; then
PATH="$HOME/bin:$PATH"
fi
I am not irrational, I'm just quantum probabilistic.
Re: Debian 11 set path at login ?
I reached the same conclusion !!!
But added "export PATH" after the if...fi lines.
Thanks for the help !!!
But added "export PATH" after the if...fi lines.
Thanks for the help !!!
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
That's cool. I found that it worked without adding export PATH. But if it works for you then go with it. But it would be nice to find out why the code in ~/.profile doesn't work as one would think it should. But then again I am NOT an expert, so maybe what I think I understand is totally wrong. Wouldn't be the first, or last, time.
I am not irrational, I'm just quantum probabilistic.
-
- Posts: 1101
- Joined: 2016-01-07 12:25
- Has thanked: 5 times
- Been thanked: 16 times
Re: Debian 11 set path at login ?
It could be that you have a (global settings) bash.bashrc file in /etc/ that gets called and therefore prevents the .profile in ~/ being called, I haven't looked into this recently but am going from memory when I wanted my ~/bin/ added to $PATH.
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
Well, there is certainly a /etc/bash.bashrc file. I certainly don't have the indepth system knowledge to understand why that would prevent ~/.profile from being called. From everything I have read, and misunderstood, ~/.profile is supposed to be called because it has specifics for the user. But then again, as VM Smith said, I am but an egg!Dai_trying wrote: ↑2021-08-30 17:26 It could be that you have a (global settings) bash.bashrc file in /etc/ that gets called and therefore prevents the .profile in ~/ being called, I haven't looked into this recently but am going from memory when I wanted my ~/bin/ added to $PATH.
I am not irrational, I'm just quantum probabilistic.
- ticojohn
- Posts: 1284
- Joined: 2009-08-29 18:10
- Location: Costa Rica
- Has thanked: 21 times
- Been thanked: 44 times
Re: Debian 11 set path at login ?
Okay. Doing some research and I HOPE I got this correct. From what I read , ~/.profile gets executed when you log in via an interactive login shell but not when you log in to a graphical environment. Hence, one needs to put the code to add the $HOME/bin path at the end of $HOME/.bashrc if you want that path added automatically at log in.
It would be nice if an expert could confirm my conclusion.
It would be nice if an expert could confirm my conclusion.
I am not irrational, I'm just quantum probabilistic.
- craigevil
- Posts: 5391
- Joined: 2006-09-17 03:17
- Location: heaven
- Has thanked: 28 times
- Been thanked: 39 times
Re: Debian 11 set path at login ?
This is what I get:
I took the info from .profile and added it to my .bashrc
Then I ran
All is good.
Edit:
Nope closing the terminal and opening a new one doesn't show it until I add:
PATH="$HOME/bin:$PATH"
to my ~.bashrc
Code: Select all
echo $PATH
/home/pi/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/lib/surfraw:/usr/lib/surfraw:/usr/lib/surfraw:/usr/lib/surfraw
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
Code: Select all
source ~/.bashrc
Edit:
Nope closing the terminal and opening a new one doesn't show it until I add:
PATH="$HOME/bin:$PATH"
to my ~.bashrc
Last edited by craigevil on 2021-08-30 19:41, edited 2 times in total.
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian Sid Kernel: 5.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list