6

When logging in to a Linux/Unix system via the old Bourne shell (sh), we have the .profile file to customize our environment for us. Some sources also reference either a .shinit file or a .shrc file. When is it appropriate to use one of these and what's the difference between them?

1 Answers1

9

.profile is only run when a login shell is started. If you want a script to run for every shell, you set the ENV environment variable to the name of this shell, and the shell will execute it. You can name this file whatever you want, .shinit and .shrc are common names.

You would use this script to set options that need to be set in each shell instance, because they're not automatically inherited as part of the environment.

Note that bash doesn't require this environment variable, it will load .bashrc by default.

See also Difference between Login Shell and Non-Login Shell?

Barmar
  • 9,927
  • While this information is accurate, it does not explain the use of nor the difference between the .shinit and .shrc files. – user174342 Jun 10 '16 at 17:16
  • 1
    There is no difference. You can use any name you want, you just put it in the ENV variable. – Barmar Jun 10 '16 at 18:31