Linux 在 Ubuntu 上永久更改 PATH

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

change PATH permanently on Ubuntu

linuxunixubuntupath

提问by socksocket

I'd like to add to PATH the value ":/home/me/play/"
for the installation of Play! framework.
so I ran this command:

我想为 PATH 添加值 ":/home/me/play/"
以安装 Play!框架。
所以我运行了这个命令:

PATH=$PATH:/home/me/play

it worked. but in the next time I checked, the value changed back to the old one.

有效。但是在我下次检查时,该值又变回了旧值。

so I guess I didn't "saved" the new value, right?

所以我想我没有“保存”新值,对吧?

how do you do that?

你是怎样做的?

采纳答案by lollo

Add

添加

export PATH=$PATH:/home/me/play

to your ~/.profileand execute

给你~/.profile并执行

source ~/.profile 

in order to immediately reflect changes to your current terminal instance.

以便立即反映对当前终端实例的更改。

回答by Danil Speransky

Try to add export PATH=$PATH:/home/me/playin ~/.bashrc file.

尝试添加export PATH=$PATH:/home/me/play~/.bashrc 文件。

回答by ndeverge

Add the following line in your .profilefile in your home directory (using vi ~/.profile):

.profile在您的主目录中的文件中添加以下行(使用vi ~/.profile):

PATH=$PATH:/home/me/play
export PATH

Then, for the change to take effect, simply type in your terminal:

然后,要使更改生效,只需在您的终端中输入:

$ . ~/.profile

回答by Brian Cain

Assuming you want to add this path for all users on the system, add the following line to your /etc/profile.d/play.sh(and possibly play.csh, etc):

假设您要为系统上的所有用户添加此路径,请将以下行添加到您的/etc/profile.d/play.sh(可能play.csh,等等):

PATH=$PATH:/home/me/play
export PATH