I'm studying the scripts that run before a bash shell started by the user starts.

As far as I understand, the order is:

  • /home/username/.bashrc (modifiable by user)
  • /etc/bashrc (modifiable by root)
  • /etc/profile.d (modifiable by root)

Does this mean that the user could change .bashrc to prevent the new shell from running bashrc and profile.d? Isn't this a security problem if the admin wanted to run some script to prevent the user from doing something when a new shell is instantiated?

  • 2
    You may compare your findings/understanding with what the manual says under the section "INVOCATION". Also, I can't think of a situation where an admin could or wanted to prevent the user from doing something in their .bashrc file. Could you give a scenario? If the account is restricted in various ways, the user may be given a restricted shell (see "RESTRICTED SHELL" in the manual). – Kusalananda Dec 19 '18 at 15:47
  • This is a pretty nice article illustrating the flow through the different startup files. – Benjamin W. Dec 19 '18 at 16:10
  • @BenjaminW. Some of the stuff there depends heavily on how the default files (both under /etc and in the user's home directory) are set up to source each other. This will differ between Unix systems. The best thing is to read one's own manual (which may be different between systems) and to read one's own files, both under /etc and in one's home directory. – Kusalananda Dec 19 '18 at 16:39
  • @Kusalananda Agree – I do like the article to get at least an idea of what could happen, and as a template to trace the flow in your own setup. – Benjamin W. Dec 19 '18 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.