Linux 什么是 .bashrc - 如何找到启动文件 - putty
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20384075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is .bashrc - How to find the startup file - putty
提问by MistyD
I was going over this articleand it states in step 3
我正在阅读这篇文章,它在第 3 步中说明
Add the following to your .bashrc (or the appropriate startup file for your shell) To use it immediately, be sure to type “source .bashrc”
Any idea on how I could know what my startup file is ? I am using putty ?
关于如何知道我的启动文件是什么的任何想法?我在用腻子?
采纳答案by JDubTech
Once you use putty to SSH into your server, you can run "ls -al .bashrc" and it should show you the file, edit this with an editor you know, if none, then use vi like this "vi .bashrc".
一旦您使用 putty 通过 SSH 连接到您的服务器,您就可以运行“ls -al .bashrc”,它应该会向您显示该文件,使用您知道的编辑器对其进行编辑,如果没有,则像这样使用“vi .bashrc”。
Go to where you need to edit the file and type in "i" to put vi in Insert mode. Next type in your text. Once you are done press the escape button and ":wq", no quotes for the i or :wq.
转到您需要编辑文件的位置并输入“i”以将 vi 置于插入模式。接下来输入您的文本。完成后按转义按钮和“:wq”,i 或:wq 没有引号。
Next you can source it by typing "source .bashrc" and the setting you added should be part of your BASH shell environment now.
接下来,您可以通过键入“source .bashrc”来获取它,您添加的设置现在应该是您的 BASH shell 环境的一部分。
回答by hek2mgl
The .bashrc
is a file which is called by bash before on each start of a new interactive shell. The file can be used to setup the environment, export variables, create aliases and functions and more...
这.bashrc
是一个文件,在每次启动新的交互式 shell 之前由 bash 调用。该文件可用于设置环境、导出变量、创建别名和函数等等...
There are usually multiple instances of that file. One per system and one per user to allow system wide configuration but also customization by users ( users bashrc will be sourced after the system wide bashrc and can overwrite things). I suggest to add the lines to your user's bashrc first. The file is located in your home folder. Type:
该文件通常有多个实例。每个系统一个,每个用户一个,允许系统范围的配置,但也允许用户自定义(用户 bashrc 将在系统范围的 bashrc 之后获得,并且可以覆盖内容)。我建议先将这些行添加到您用户的 bashrc 中。该文件位于您的主文件夹中。类型:
vi $HOME/.bashrc
in order to edit the file. If you aren't familiar with the vi
editor you can choose an editor of your choice like nano
, mcedit
or even a GUI text editor, but mind that a GUI editor's file dialog may hide the file because it's name starts with a .
以便编辑文件。如果您不熟悉vi
编辑器,您可以选择您喜欢的编辑器nano
,mcedit
甚至是 GUI 文本编辑器,但请注意 GUI 编辑器的文件对话框可能会隐藏该文件,因为它的名称以.
Once you managed to edit the file, start a new connection or simply type
设法编辑文件后,开始新的连接或只需键入
source $HOME/.bashrc
in order to parse the file
为了解析文件
回答by Ayush Kumar Sharma
check your home directory ...because it exists in user's home directory.
检查您的主目录...因为它存在于用户的主目录中。
check /home/username/on your terminal if you are using RHEL or CentOS.
如果您使用的是 RHEL 或 CentOS,请检查终端上的/home/username/。
回答by kt-0
A path which will work with any bash shell regardless of operating system (macOS/Linux/BSD etc.) is:
无论操作系统(macOS/Linux/BSD 等)如何,都可以与任何 bash shell 一起使用的路径是:
~/.bashrc