Understanding shell profiles in RHEL

Solution Verified - Updated -


  • Red Hat Enterprise Linux (RHEL)


  • We are coming from Solaris environment to RHEL. Normally we only work with ~/.profile to have the profile set up for each user. We recently experienced problem setting them up and RHEL documents request me to change ~/.bashrc.

  • It seems like it changes for bash shell. If we are using a different shell (example ksh), then would ~/.kshrc be the file to control the profile?
    I also see ~/.profile created as we run oracle. Where does ~/.profile come to play?

  • Is there a document that specifically explains the profile set up? I would like to fully understand all of these files:



First of all, the files in the /etc directory are global for all users, but 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). For more information on profile.d, please refer to How do I use custom.sh for a global user profile in RHEL 6?

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.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.