什么是的.bashrc,.bash_profile中,并.environment之间的区别? [英] What's the difference between .bashrc, .bash_profile, and .environment?

查看:254
本文介绍了什么是的.bashrc,.bash_profile中,并.environment之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了许多岁月的不同的基于* NIX系统,并且好像猛砸每一种滋味我使用有决定哪些启动脚本运行不同的算法。对于任务像设置环境变量和别名和印刷启动信息(例如MOTDs),它的启动脚本是适当的地方做这些目的是什么?

I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run. For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate place to do these?

有什么东西将在的.bashrc 的.bash_profile 的区别。环境?我也看到其他文件,如的.login .bash_login文件 .profile文件;这些以往有关?什么是哪些得到在登录时身体上,通过SSH远程登录,并打开一个新的终端窗口中运行的区别在哪里?是否有跨平台(包括Mac OS X(及其Terminal.app)和Cygwin bash)的?

What's the difference between putting things in .bashrc, .bash_profile, and .environment? I've also seen other files such as .login, .bash_login, and .profile; are these ever relevant? What are the differences in which ones get run when logging in physically, logging in remotely via ssh, and opening a new terminal window? Are there any significant differences across platforms (including Mac OS X (and its Terminal.app) and Cygwin Bash)?

推荐答案

与外壳配置文件的主要区别在于,有些只有登录弹阅读(例如,当您从另一台主机,或在文本登录密码本地UNIX计算机的控制台)。这些都是所谓的,比方说,的.login .profile文件 .zlogin (具体取决于哪个壳您正在使用)。

The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using).

然后,你必须由互动弹读(如配置文件,那些连接到终端(或伪终端,比如说,在一个窗口系统运行终端仿真器的情况下)。这些都是那些像的.bashrc .tcshrc文件 .zshrc 等。

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

庆典变得较为复杂这在的.bashrc 只有一个外壳,是同时读取的互动的和的非登录,所以你会发现大多数人最终会告诉他们的的.bash_profile 来也看过的.bashrc 的东西,如

bash complicates this in that .bashrc is only read by a shell that's both interactive and non-login, so you'll find most people end up telling their .bash_profile to also read .bashrc with something like

[-r的〜/ .bashrc]&放大器;&安培; 。在〜/ .bashrc

其他炮弹不同的表现 - 如使用的zsh .zshrc 总是读一个交互式shell,无论是登录一个或没有。

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

对于bash的手册页解释下,每个文件被读取的情况。是的,行为是机器之间基本一致。

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile文件仅仅是登录脚本文件名最初由 / bin / sh的庆典,是与 / bin / sh的一般向后兼容,会读 .profile文件(如果存在)。

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.

这篇关于什么是的.bashrc,.bash_profile中,并.environment之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆