Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #276015

Re: bashrc question

From henrik@privatembox.com
Newsgroups linux.debian.user
Subject Re: bashrc question
Date 2024-12-26 09:30 +0100
Message-ID <JXRpM-2MuJ-1@gated-at.bofh.it> (permalink)
References <JXMT7-2HHN-5@gated-at.bofh.it> <JXNct-2HOe-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 26.12.2024 04:52, Greg Wooledge wrote:
> 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?

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

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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