On Thu, Mar 26, 2020 at 8:29 AM B Stone <bvstone@xxxxxxxxx> wrote:
I am wondering what the best practice for a global .profile file would be,
That's a good question, and well-studied question in the *nix world.
and if used, would a personal .profile (/home/[user]/.profile) file be able
to override and/or add to the global settings.
This is a good example of why everyone in the IBM i open source world
should have a Linux instance nearby as a reference.
Here is an assortment of facts from the world of Linux and other *nix
operating system:
   - When a user is created via useradd -m they are assigned a default
   shell and appropriate default profile files are created in their home dir.
   - The administrator can edit the master copies of the default profile
   files that are copied to the user's directory. These may or may not include
   (e.g., for a bash user):
   - .profile
      - .bash_profile
      - .bash_rc
      - etc ...
      - The accessing of a file in the current shell level so that any
   variables set at that level persist after the access is called "sourcing",
   as when you source foo.sh or . foo.sh
   - A login shell sources .profile first.
   - Then it loads the user's default shell.
   - That shell follows its own rules for automatic sourcing of shared
   files.
      - On a Linux system type man bash to see what bash does.
      - Invariably, the user's home dir files are sourced last and override.
Or am I barking up the wrong tree entirely?  :)
Just write what you want in .profile and leave it in user's home dir.
If user's shell is bash, add a coda in the .profile that reads:
#if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi
... and put all your bash-y stuff in .bashrc
As an Amazon Associate we earn from qualifying purchases.