bash 如何在 ubuntu 中的 .profile 或 .bash_profile 中设置 PATH

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38151964/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:51:12  来源:igfitidea点击:

How to set the PATH in .profile or .bash_profile in ubuntu

linuxbashshellubuntupath

提问by user6348718

I have a script which uses jmeter. Now, instead of giving the path in the script like sh /home/ubuntu/apache-jmeter-3.0/bin/jmeter.sh -n -t fileName.jmxin the script I just want to give sh jmeter.sh -n -t fileName.jmxin the script. So, I want to set up the PATH of the jmeterin ubuntu. I didn't understand how to do it. Can some one help.

我有一个使用 jmeter 的脚本。现在,不是像sh /home/ubuntu/apache-jmeter-3.0/bin/jmeter.sh -n -t fileName.jmx在脚本中那样在脚本中提供路径,我只想sh jmeter.sh -n -t fileName.jmx在脚本中提供。所以,我想设置jmeterin的 PATH ubuntu。我不明白该怎么做。有人可以帮忙吗。

Path to my jmeter is: /home/ubuntu/apache-jmeter-3.0

我的 jmeter 的路径是: /home/ubuntu/apache-jmeter-3.0

采纳答案by heemayl

Add the directory /home/ubuntu/apache-jmeter-3.0/binto your path:

将目录添加/home/ubuntu/apache-jmeter-3.0/bin到您的路径中:

export PATH="$PATH":/home/ubuntu/apache-jmeter-3.0/bin

Then you can use it directly:

然后就可以直接使用了:

jmeter.sh -n -t fileName.jmx

To make it permanent, add the new PATHdeclaration to your ~/.bashrc.

要使其永久化,请将新PATH声明添加到您的~/.bashrc.