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?
Asked
Active
Viewed 1.1k times
6

user174342
- 61
1 Answers
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?
.shinit
and.shrc
files. – user174342 Jun 10 '16 at 17:16ENV
variable. – Barmar Jun 10 '16 at 18:31