如何在 Mac OSX Snow Leopard 上修复 bash 中的路径变量

发布于 2024-09-18 11:58:37 字数 500 浏览 15 评论 0原文

这可能是一个菜鸟问题,但我需要帮助。我尝试使用以下命令更改路径变量,从而搞砸了终端:

$ sudo nano .profile

在执行此操作之前,如果我要输入: $ echo $PATH

我会得到: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

当我在 nano 中打开 .profile 时,它​​告诉我该文件不存在。我认为这是有道理的,因为我以前从未编辑过这个文件。我继续输入用于 php 框架的目录路径并保存文件。

保存文件后,我注意到我的 bash 命令都不起作用。现在我无法从终端执行任何操作。我什至无法在 nano 中编辑 .profile,因为它显示 -bash: nano: command not find

我显然是使用终端的新手。我感觉完全迷失了。请提供一些有关如何将终端恢复到工作状态的指导。

This might be a noob question, but I need help. I screwed up my terminal by trying to alter my path variable using the following command:

$ sudo nano .profile

Before I did that, if I were to type:
$ echo $PATH

I would get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

When I opened .profile in nano it told me that the file didn't exist. I figured that made sense, since I had never edited this file before. I proceeded to enter a path to a directory I was using for a php framework and saved the file.

After I saved the file, I noticed that none of my bash commands are working. Now I can't do anything from the terminal. I can't even edit .profile in nano because it says -bash: nano: command not found

I'm clearly new to working with the terminal. I feel completely lost. Please provide some guidance on how to restore the terminal to working condition.

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

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

发布评论

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

评论(2

梦言归人 2024-09-25 11:58:37

使用绝对路径。

 $  /usr/bin/sudo /usr/bin/nano .profile

如果您向路径添加某些内容,切勿只是执行操作

 PATH=/path/to/something

,而是执行操作

 PATH=$PATH:/path/to/something

顺便说一句,您不应该/不必使用 sudo 来编辑您自己的文件,例如 .profile< /代码>。仅当您需要编辑不属于您帐户的文件时才使用 sudo

Use absolute paths.

 $  /usr/bin/sudo /usr/bin/nano .profile

If you add something to a path, never just do

 PATH=/path/to/something

instead do

 PATH=$PATH:/path/to/something

By the way, you shouldn't/don't have to use sudo to edit your own file, such as .profile. Use sudo only when you need to edit the file which doesn't to belong to your account.

池木 2024-09-25 11:58:37

我也有同样的问题!
我解决的方法是在终端中编写以下命令:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin

希望可以对你有用

I had the same problem!
The way I solved was writing the follow command in the terminal:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin

Hope it can be useful for you

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