I'd like to put code into a file, which when a new session is made is invoked for all users on a Debian system.
/etc/profile
is only touched by login sessions.
I'd like to put code into a file, which when a new session is made is invoked for all users on a Debian system.
/etc/profile
is only touched by login sessions.
File which is invoked by all users for new bash sessions
When you read the chapter on Invocation in the manual you'll know that there is no such file. https://linux.die.net/man/1/bash
I don't have a Debian box at hand but it might be that Debian does something similar to what RHEL/CentOS do: by default those distro's deploy from /etc/skell
both a ~/.bash_profile
and a ~/.bashrc
to the users home directory.
When bash is invoked as an interactive login shell the ~/.bash_profile
should be loaded.
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc
By loading the ~/.bashrc
from ~/.bash_profile
you get a file that will be loaded for both normal and login sessions.
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
The ~/.bashrc
in turn will load global /etc/bashrc
and you get a system wide file that gets loaded for both login as well as non-login interactive bash sessions.