Bash Profile vs. RC: A Comprehensive Guide to Shell Configuration
In Bash, 'profile' and 'rc' files are both used for configuring and defining a user's environment variables, aliases, functions, and more. The key distinction lies in their purpose and loading mechanisms.
-
'Profile' Files:
- These files are typically loaded upon user login, establishing global environment variables and paths. The specific file loaded depends on the login method:
- For login shells, '/etc/profile' and '~/.bash_profile' (or '~/.bash_login' or '~/.profile' if the former two don't exist) are loaded.
- For non-login shells, '~/.bashrc' is loaded.
- These files are typically loaded upon user login, establishing global environment variables and paths. The specific file loaded depends on the login method:
-
'RC' Files:
- 'RC' files are loaded at shell startup, tailoring your personal shell environment with aliases, functions, etc. The loading is straightforward: '~/.bashrc' is loaded for both login and non-login shells.
In essence:
- 'Profile' files configure global settings, primarily during login.
- 'RC' files manage your individual shell settings, loaded whenever a shell starts.
原文地址: https://www.cveoy.top/t/topic/qg3v 著作权归作者所有。请勿转载和采集!