Wednesday, June 2, 2021

Linux ENV Setings ---- /etc/profile /etc/bashrc ~/.bashrc ~/.bash_profile

export PATH=$PATH:/usr/local/bin/nodeSetup/

Any Folder Path we put on PATH is scanned for Executables


~/.bash_profile
~/ .bashrc
~/.profile

/etc/sudoers
/etc/yum.conf
/etc/os-release
/etc/hosts
/etc/hosts.allow
/etc/fstab
/etc/shells

/etc/passwd
/etc/group
/etc/shadow

/etc/profile
etc/bashrc      [/etc/profile.d]

/etc/bashrc          # Functions and aliases go in /etc/bashrc
/etc/profile            # System wide environment and startup programs, for login setup + Environment stuff (It sources/executes shell in /etc/profile.d)
/etc/profile.d        # It's much better to create a custom.sh shell script in  /etc/profile.d/ to make custom changes to your environment 

~/.bash_profile    # User specific environment and startup programs    #PATH=$PATH:$HOME/.local/bin:$HOME/bin       #export PATH --- It sources(executes)  ~/.bashrc
~/.bashrc              #Get the aliases and functions                                              

-----------------------------------------------------------------------------
/etc/profile file is used to set system wide environmental variables on users shells. 
/etc/profile is the system wide version of .bash_profile.

/etc/bashrc for Red Hat and /etc/bash.bashrc in Ubuntu is the system wide version of .bashrc.

.bashrc file in your home directory. 
This file is meant for setting command aliases and functions used by bash shell users

.bash_profile or .profile - in  your home directory.
These files are used to set environmental items for a particular user's shell

The difference is simple, 
/etc/profile is executed only for interactive shells 
/etc/bashrc is executed for both interactive and non-interactive shells.
-------------------------------------------------------------------------------


For User specific Stuff, You can put aliases in ~/.bashrc and ~/.bash_profile sources it , but ENV Paths etc should be put in ~/.bash_profile

For Stuff relevant to all , You should put stuff in custom shell inside /etc/profile.d 

https://shreevatsa.files.wordpress.com/2008/03/bashstartupfiles1.png
https://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/

The importance of using a login shell is that any settings in /home/user/.bash_profile will get executed.






No comments:

Post a Comment

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass