Linux 在 Ubuntu 中将目录添加到 PATH
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7360889/
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
Adding a directory to PATH in Ubuntu
提问by Tofayel Ahmed
I am a new user of Linux, just switched from Windows. I installed ActiveTcl-8.5 in /opt/ActiveTcl-8.5/
, now I want to add its bin
directory to the UNIX path.
我是 Linux 的新用户,刚从 Windows 切换过来。我在 中安装了 ActiveTcl-8.5 /opt/ActiveTcl-8.5/
,现在我想将其bin
目录添加到 UNIX 路径中。
I have read a number of articles from the net and got confused about which file to modify. My /home/tofayel
directory contains .bashrc
, .bash_logout
, .bash_history
, and .profile
; but not .bash_login
and .bash_profile
.
我从网上阅读了许多文章,并对要修改的文件感到困惑。我的/home/tofayel
目录包含.bashrc
, .bash_logout
, .bash_history
, 和.profile
; 但不是.bash_login
和.bash_profile
。
Where do I add the extra lines to add /opt/ActiveTcl-8.5/bin
to PATH?
我在哪里添加要添加/opt/ActiveTcl-8.5/bin
到 PATH的额外行?
回答by Fredrik Pihl
The file .bashrc
is read when you start an interactive shell. This is the file that you should update. E.g:
.bashrc
当您启动交互式 shell 时会读取该文件。这是您应该更新的文件。例如:
export PATH=$PATH:/opt/ActiveTcl-8.5/bin
Restart the shell for the changes to take effect or source it, i.e.:
重新启动外壳以使更改生效或获取它,即:
source .bashrc
回答by reader_1000
you can set it in .bashrc
你可以在 .bashrc 中设置它
PATH=$PATH:/opt/ActiveTcl-8.5/bin;export PATH;
回答by tripleee
Actually I would advocate .profile
if you need it to work from scripts, and in particular, scripts run by /bin/sh instead of Bash. If this is just for your own private interactive use, .bashrc
is fine, though.
实际上,我建议.profile
您是否需要它从脚本中工作,特别是由 /bin/sh 而不是 Bash 运行的脚本。不过,如果这只是为了您自己的私人互动使用,那.bashrc
很好。