On 26.12.2024 04:52, Greg Wooledge wrote:
On Thu, Dec 26, 2024 at 04:16:17 +0100, hen...@privatembox.com wrote:
Hello
I have these settings in .bashrc of my home dir:
$ cat .bashrc
export TF_CPP_MIN_LOG_LEVEL=3
export CUDA_VISIBLE_DEVICES=-1
but every time after i login the system, the settings are not
activated.
I have to source it by hand to make it work.
what's wrong with me?
1) What shell do you use?
Hi Greg,
The shell i am using is bash.
$ echo $SHELL
/bin/bash
2) How do you get to a terminal?
Just ssh to remote host to get a terminal. My ssh client is in Mac's
terminal.
If you're not using bash as your login shell, then it makes perfect
sense .bashrc wouldn't be read.
If you open a terminal which works *normally*, it should run a
non-login
shell, which in the case of bash should read .bashrc.
what's non-login shell and login shell? i am not sure about this.
However, if your terminal has been configured to run a login shell,
then it will read .bash_profile or .bash_login or .profile instead.
However however, your .profile or equivalent should be configured to
dot in your .bashrc file, possibly after verifying that you are, in
fact, in bash.
$ ls .bash_profile
ls: cannot access '.bash_profile': No such file or directory
$ ls .bash_login
ls: cannot access '.bash_login': No such file or directory
$ ls .profile
ls: cannot access '.profile': No such file or directory
I have no these three files in my home dir.
A .profile which fails to dot in .bashrc will lead you to all kinds of
subtle problems whenever you launch a login shell, which would normally
be when you ssh in, or login on a text console.
A terminal emulator should normally run a NON-login shell, but some of
them are sometimes configured to do the wrong thing because it works
around stupid users. So, if you're using a Desktop Environment that
assumes you are a stupid user, it might be running your shell as a
login
shell.
You can tell whether your shell is a login shell by looking at the
name it's invoked with (via ps(1) or similar commands). If the
invocation name begins with a hyphen ("-"), it's a login shell.
hobbit:~$ ssh localhost
greg@localhost's password:
Linux hobbit 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1
(2024-11-22) x86_64
[...]
hobbit:~$ ps -fp $$
UID PID PPID C STIME TTY TIME CMD
greg 1001894 1001893 0 22:46 pts/29 00:00:00 -bash
That's a login shell, because I ssh'ed in. You can tell because it's
invoked as "-bash" instead of "bash". As a login shell, it will read
my .profile, and my .profile contains:
$ ps -fp $$
UID PID PPID C STIME TTY TIME CMD
pyh 52921 52920 0 08:13 pts/0 00:00:00 -bash
This is my ps result, it seems I am using a login shell.
But as I said above, I have no .profile in my home dir.
hobbit:~$ grep bashrc .profile
. ./.bashrc
so that my .bashrc file is *also* read. Yours should have this too,
or something fancier, maybe even
test "$BASH" && source ~/.bashrc
or the default Debian /etc/skel/.profile way:
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
which is ridiculously verbose. I went with a more basic route.
So, since I am using a login shell, and I have .bashrc created. thus I
have to create a .profile to include .bashrc? Am I right?
Thank you a lot.
Henrik