在 Ubuntu 10.10 中永久更改环境变量

发布于 2024-11-04 09:48:26 字数 530 浏览 1 评论 0原文

朋友们, 我想在系统范围内更改环境路径。因为我有一个名为“md5”的程序。我想从任何地方(即任何目录)执行它。

我的 md5 程序位于“/home/ahuq/MappingServer/md5_program”。所以我所做的就是在运行的SHELL中添加:“export PATH=$PATH:/home/ahuq/MappingServer/md5_program”。这只会进行临时更改,并让我可以从任何地方临时运行“md5”程序。但我想让这个改变永久化。所以我所做的就是将“PATH=$PATH:/home/ahuq/MappingServer/md5_program”行放入“/etc/environment”文件中。这把一切都搞砸了,然后有一段时间我无法从 SHELL 执行任何东西。我知道“nano”编辑器的绝对路径,并用它来将文件(即/etc/environment)修改回其原始状态。这解决了问题,现在我可以从 SHELL 运行“ls”之类的程序。

但我仍然需要一种方法将“md5”的路径永久添加到环境中。我怎样才能在 Ubuntu 10.10 中做到这一点?需要编辑哪个文件?

再见。

Friends,
I want to make change to environment PATH system wide. Because I have program called "md5". I want to execute it from anywhere (i.e any directory).

My md5 program is located at "/home/ahuq/MappingServer/md5_program". So what I did was to put: "export PATH=$PATH:/home/ahuq/MappingServer/md5_program" in the running SHELL. This only makes temporary changes and lets me run the "md5" program from anywhere temporarily. But I want to make this change permanent. So what I did was to put the "PATH=$PATH:/home/ahuq/MappingServer/md5_program" line into the "/etc/environment" file. This screwed everything up and then for a while I couldn't execute anything from SHELL. I knew the absolute path of "nano" editor and used it to modify the file (i.e. /etc/environment) back to its original condition. This fixed the problem and now I can run programs like "ls" from the SHELL.

But still I need a way to permanently add the path of "md5" to the environment. How can I do this in Ubuntu 10.10? Which file needs to edited?

Bye.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅渡 2024-11-11 09:48:26

看起来您将“程序”添加到路径中,您只想将目录添加到路径中。

尝试

PATH=$PATH:/home/ahuq/MappingServer

添加到 .profile 中定义 PATH 的位置。

我希望这有帮助。

PS,由于您似乎是新用户,如果您得到的答案对您有帮助,请记住将其标记为已接受,和/或给它 +(或 -)作为有用的答案。

It looks like your adding the 'program' to the path, you only want to add the directory to the path.

Try

PATH=$PATH:/home/ahuq/MappingServer

added to where your PATH is defined in a .profile.

I hope this helps.

P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文