bash 添加到 .bashrc 文件的路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13631173/
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 path to the .bashrc file?
提问by user1825241
At the moment I am trying to add a path for ns-2 to my .bashrc file, I have installed the ns-allinone-2.34 but the command ns gives the result: command not found when entered into the shell.
目前,我正在尝试将 ns-2 的路径添加到我的 .bashrc 文件中,我已经安装了 ns-allinone-2.34,但是命令 ns 给出了结果:进入 shell 时找不到命令。
Here is what my .bashrc file currently looks like, I edited it using gedit:
这是我的 .bashrc 文件当前的样子,我使用 gedit 对其进行了编辑:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export PATH=/home/michael/ns-allinone-2.34/bin/ns:/home/michael/ns-allinone-2.34/bin/nam:$PATH
Can someone please explain why this isn't working or what a possible solution may be? I am using fedora 17.
有人可以解释为什么这不起作用或可能的解决方案是什么?我正在使用 Fedora 17。
采纳答案by Brian Agnew
The PATH
should contain the directoryfor the binaries, not the binaries themselves.
本PATH
应包含目录的二进制文件,而不是二进制文件本身。
For example, in the above:
例如,在上面:
export PATH=/home/michael/ns-allinone-2.34/bin/ns:..
should actually be:
实际上应该是:
export PATH=/home/michael/ns-allinone-2.34/bin:...
回答by user1830432
Also if you export path like this, you want to keep old PATH as well, therefore include it as well.
此外,如果您像这样导出路径,您也希望保留旧的 PATH,因此也包括它。
export PATH=$PATH:/home/michael/ns-allinone-2.34/bin/