如何在 Mac OSX Snow Leopard 上修复 bash 中的路径变量
这可能是一个菜鸟问题,但我需要帮助。我尝试使用以下命令更改路径变量,从而搞砸了终端:
$ 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用绝对路径。
如果您向路径添加某些内容,切勿只是执行操作
,而是执行操作
顺便说一句,您不应该/不必使用
sudo
来编辑您自己的文件,例如.profile< /代码>。仅当您需要编辑不属于您帐户的文件时才使用
sudo
。Use absolute paths.
If you add something to a path, never just do
instead do
By the way, you shouldn't/don't have to use
sudo
to edit your own file, such as.profile
. Usesudo
only when you need to edit the file which doesn't to belong to your account.我也有同样的问题!
我解决的方法是在终端中编写以下命令:
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