Re: Where is PATH stored these days ? Why isn't .bash_profile executed in F35 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11Jan2022 14:15, linux guy <linuxguy123@xxxxxxxxx> wrote:
>I'm trying to add a few directories to PATH in F35.  I'm embarrassed to
>admit it isn't going well.
>
>Where is PATH stored in F35 ?

In your processes' memory. Unhelpful. But it is _initialised_ by your 
login sequence. Yes, being pedantic here.

>When exactly does .bash_profile get executed ?

1: Is your shell bash? (My interactive shell is zsh, by contrast.) 
Echoing $SHELL should confirm bash for you, or looking in /etc/passwd.

2: .bash_profile (or .profile, if the former is missing) gets run by 
_login_ shells.

On a text based terminal (eg the Linux console without a GUI), your 
login runs a login shell.

In a GUI such as a desktop the situation is more complicated:

- the GUI startup does not automatically run a login shell (to some 
  extend because interaction or mistakes can then easily break the GUI 
  startup).

- when you start a terminal it may or may not run a login shell; this 
  can be controlled with the settings for your terminal emulator. What 
  are you using?

Shells usually have a login and nonlogin startup mode - for bash this 
loosely means a login shell sources the .bash_profile (or.profile) on 
startup, and nonlogin interactive shells source the .bashrc. The 
specifics vary for other shells (eg zsh) but the idea's the same. The 
exact process for bash is explained in tedious details in "man bash".

The basic idea is/was that you'd put expensive stuff which only needed 
to happen once in the .bash_profile (setting $PATH, consulting some 
summary information, etc) and interactive-useful stuff in your .bashrc 
(setting interaction modes like command line editing, defining aliases, 
etc).

These days you can often get away with making every new terminal run a 
login shell. Look into that setting first up - it is the easiest fix.

I discourage you from polluting your .bashrc with complexity. Though a 
lot of distros prepollute it for you (have a look at /etc/bashrc, often 
a nightmare of complexity).

Personally, I keep my environment setting stuff in a distinct script, 
which I source from my .profile. Here's my .profile:

    #!/bin/sh
    umask 002
    [ -f $HOME/rc-local/profile ] && . $HOME/rc-local/profile
    : ${SHDIR:=$HOME/rc/shell}
    . $SHDIR/rigenv
    LUSER=$USER; export LUSER
    . $HOME/rc/shell/rc

Setting $PATH (and a billion other things) is done in the "rigenv" 
script mentioned above.

>How does one get the bash environment reloaded without logging out and
>logging in ?   $source <something> ?  $exec bash ?  ./bash ?

If your terminals run login shells, opening a new terminal will do. For 
that terminal, of course.

Or you can source your .profile (or separate script):

    . ~/.bash_profile

>$env should include everything in .bash_profile, right ?

"env" shows the exported environment - that which is inherited by 
subprocesses. Example:

    foo=bah
    PATH=$HOME/bin:$PATH:/usr/local/bin
    export PATH

$PATH gets exports, $foo does not, so env will show $PATH and not $foo.  
But your local shell has $foo for whatever purpose.

Note that _inherited_ variables are automatically reexported. Because if 
this, good practice is to only export $UPPERCASE names, and to use 
$lowercase names for unexprted variables. This is because only 
discipline controls the use of this namespace. besides, it also makes it 
obvious which variables you expect to be local and which exported.

>Why doesn't F35 have ~/.profile or ~/.bashrc and instead has
>~/.bash_profile ?  Does .bash_profile replace .bashrc and .profile ?  Would
>bash read .profile if I created one ?  If so, when ?

See "man bash". Bash uses .bash_profile for logins and .bashrc for 
nonlogin interactive shells.

>What happened to .inputrc ?

The .inputrc is for controlling the readline library (used for 
interaction in bash and various other things). Maybe the defaults are 
considered nice enough - you can always add your own. Here's mine:

    set editing-mode emacs
    set blink-matching-paren on
    set completion-ignore-case on
    set completion-query-items 1024
    set disable-completion off
    set expand-tilde on
    set horizontal-scroll-mode off
    set mark-directories on
    set mark-symlinked-directories on
    set match-hidden-files off
    set page-completions on
    set print-completions-horizontally off
    set show-all-if-ambiguous on
    set visible-stats on
    Control-w:backward-kill-word

Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux