If you are a Linux system admin you must have dealt with at least one of the shell profile files from below list in your life.
/etc/profile /etc/bashrc ~/.profile ~/.bash_profile ~/.bashrc ~/.kshrc
These files are called the shell profile files and as the name suggests they are basically used to set the environment in a specific shel. So if you want to set some variable in ksh shell, you must include that variable in ~/.kshrc file. These file resides in the home directory of the local users on the system.
The files in the /etc directory are global for all users, but one should really avoid changing them if at all possible. If need to modify the global settings, you can use /etc/profile.d (this is to prevent your changes from getting wiped out when packages are upgraded).
Now, from an individual user basis, the next question is why are there all these different files (.bashrc, .bash_profile, .profile, etc). The primary thing to understand is that the rc files are for all shell invocations while the profiles are strictly for interactive shells. On top of that, if you are going to be using both ksh and bash, you should use .profile for ksh and .bash_profile for bash. Since most configuration directives recognized by ksh are also recognized by bash, some people who use both shells find it easier to just create a symlink between the two.
There is also the matter of .kshrc, which is actually not a file that the korn shell specifically looks for. It’s just a practical convention, and many people use it, and then source the file from inside their .profile. Otherwise, ksh will not automatically read it.
How to configure custom.sh for a global user profile
If you read the /etc/profile file, you would see the warning as shown below at the start of the file.
# more /etc/profile # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates.
So it is not advised to edit the /etc/profile file directly unless you know what you are doing. Instead we can create a custom.sh script in /etc/profile.d directory. The custom.sh is a bash script run at login for all users. It can include items that you would find in a typical .bash_profile for a given user. You would use this if you wanted a global profile, even for root. Just create and edit custom.sh to setup a custom environment, such as alias and startup applications for all users.
1. First, you must setup /etc/profile.d/custom.sh:
$ touch /etc/profile.d/custom.sh $ chmod +x /etc/profile.d/custom.sh
2. Next, you must create the contents of /etc/profile.d/custom.sh. Here we are just defining an alias for the command “ls -lah”.
#!/bin/sh alias ls='ls -lah'
3. Simply log out and then log back in again. You’ll notice the changes. You can verify this particular example by using the alias command:
$ alias | tail -n1 alias ls='ls -lah'