Hi,
not a *nix geek, coming from debian and had some modifications which I'd put in debian in bash.bashrc there ... but this file seems not to exist in CentOS! I'd read some forum posts, but none shifts me in the right direction:
Where do i have to put my modification for bash (some aliases / modification for prompt). I found a file /etc/bashrc, where many lines with if/fi inside. Don't know if it's the right place, and if ... where to put my modifications in? Some forum posts pointing in direction /etc/profile.d but i don't understand what and how to modify there?!
Some saying put it there, its better then other location, others say, better put other place ... and there X possibilities ... so I'm ending up a bit confused and don't know what to do. Please can someone tell me which file is the best (i dont need 10 different possibilities) to achieve what i want.
Thx
.bashrc systemwide
Re: .bashrc systemwide
Create a new file in /etc/profile.d called something.sh and put your content in there. They're executed in alphabetical order.
Re: .bashrc systemwide
Thx for quick reply. Working wonderful!
Re: .bashrc systemwide
Captain, how on earth can we do that for non interactive shells? I am struggling here.
Need to export some variables and run a few scripts on every user login/bash shell opened.
Any way to do systemwide without the need to do that in ~/.bashrc for every single user?
Tried /etc/profile.d/ but only works for ssh.
Need to export some variables and run a few scripts on every user login/bash shell opened.
Any way to do systemwide without the need to do that in ~/.bashrc for every single user?
Tried /etc/profile.d/ but only works for ssh.
Re: .bashrc systemwide
Hello,
If your talking about a system wide bashrc on centos you'll need to look at :
That will be global. It will not stop someone from having a /home/SOME_USER/.bashrc for their account though. So, a user could set up their own bashrc file. Any way, "/etc/bashrc" would be a global though. To see how it works just do the following :
Hope that helps.
If your talking about a system wide bashrc on centos you'll need to look at :
Code: Select all
/etc/bashrc
That will be global. It will not stop someone from having a /home/SOME_USER/.bashrc for their account though. So, a user could set up their own bashrc file. Any way, "/etc/bashrc" would be a global though. To see how it works just do the following :
Code: Select all
#:printf "alias df='df -Thk'\n" >> /etc/bashrc
( exit shell and re-open. You can also just use source /etc/bashrc; however, you want to make sure your changes will take effect on a login.
#:df
Hope that helps.
Re: .bashrc systemwide
Thanks, but it wouldn't work for a terminal launched from MATE.
I had to enable it through the terminal settings to launch this as an interactive shell to get this to work.
Otherwise it wasn't going through bashrc at all.
I had to enable it through the terminal settings to launch this as an interactive shell to get this to work.
Otherwise it wasn't going through bashrc at all.
Re: .bashrc systemwide
A bash login shell first reads /etc/profile (if it exists) and then the first one it finds of ~/.bash_profile , ~/.bash_login or ~/.profile .
For a bash interactive and non-login shell, the shell reads ~/.bashrc .
A non-interactive shell reads the file ${BASH_ENV} , if that environment variable exists and the file it points to can be read.
When a user's home directory is created, the files /etc/skel/{.bash_profile,.bashrc,.bash_logout} are copied to the new home directory.
By default, the skeleton file for .bash_profile reads ~/.bashrc and the skeleton file for .bashrc reads /etc/bashrc .
So when the user has not changed the ~/.bash_profile or ~/.bashrc from what was copied from /etc/skel, both login and non-login interactive shells will read /etc/bashrc.
/etc/profile and /etc/bashrc execute the commands found in the files /etc/profile.d/*.sh (/etc/bashrc does this only for non-login shells, so it is not needlessly done twice).
When you want to add your own system wide customization for bash, create a new file in /etc/profile.d with .sh file name suffix.
@koullislp: when you launch a terminal you always launch an interactive shell in it. A terminal launched from a desktop session (like MATE) is a interactive non-login shell. When this shell has not read your customization in /etc/profile.d/*.sh , it is likely that the user does not have a ~/.bashrc or that ~/bashrc is modified and no longer reads /etc/bashrc .
Note 1: bash for security reasons skips reading ~/.bashrc if it is not owned by the user or root, or when it has write permissions for group or other.
Note 2: (syntax) errors in ~/.bashrc or ~/.bashrc_profile or other files read on start of the shell may make that only part of these files is read. So check and double check these files for errors!
For a bash interactive and non-login shell, the shell reads ~/.bashrc .
A non-interactive shell reads the file ${BASH_ENV} , if that environment variable exists and the file it points to can be read.
When a user's home directory is created, the files /etc/skel/{.bash_profile,.bashrc,.bash_logout} are copied to the new home directory.
By default, the skeleton file for .bash_profile reads ~/.bashrc and the skeleton file for .bashrc reads /etc/bashrc .
So when the user has not changed the ~/.bash_profile or ~/.bashrc from what was copied from /etc/skel, both login and non-login interactive shells will read /etc/bashrc.
/etc/profile and /etc/bashrc execute the commands found in the files /etc/profile.d/*.sh (/etc/bashrc does this only for non-login shells, so it is not needlessly done twice).
When you want to add your own system wide customization for bash, create a new file in /etc/profile.d with .sh file name suffix.
@koullislp: when you launch a terminal you always launch an interactive shell in it. A terminal launched from a desktop session (like MATE) is a interactive non-login shell. When this shell has not read your customization in /etc/profile.d/*.sh , it is likely that the user does not have a ~/.bashrc or that ~/bashrc is modified and no longer reads /etc/bashrc .
Note 1: bash for security reasons skips reading ~/.bashrc if it is not owned by the user or root, or when it has write permissions for group or other.
Note 2: (syntax) errors in ~/.bashrc or ~/.bashrc_profile or other files read on start of the shell may make that only part of these files is read. So check and double check these files for errors!