Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #276013
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: bashrc question |
| Date | 2024-12-26 05:00 +0100 |
| Message-ID | <JXNct-2HOe-1@gated-at.bofh.it> (permalink) |
| References | <JXMT7-2HHN-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Dec 26, 2024 at 04:16:17 +0100, henrik@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?
2) How do you get to a 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.
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.
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:
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.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
bashrc question henrik@privatembox.com - 2024-12-26 04:40 +0100
Re: bashrc question George at Clug <Clug@goproject.info> - 2024-12-26 04:50 +0100
Re: bashrc question Greg Wooledge <greg@wooledge.org> - 2024-12-26 05:00 +0100
Re: bashrc question henrik@privatembox.com - 2024-12-26 09:30 +0100
Re: bashrc question Chris Green <cl@isbd.net> - 2024-12-26 12:20 +0100
Re: bashrc question pocket@homemail.com - 2024-12-26 14:00 +0100
Re: bashrc question Greg Wooledge <greg@wooledge.org> - 2024-12-26 14:10 +0100
Re: bashrc question henrik@privatembox.com - 2024-12-27 01:10 +0100
Re: bashrc question Frank Jezzer <etphonehomefrance@gmail.com> - 2024-12-26 17:00 +0100
csiph-web