在 Mac OSX 10.5 中,它无法找到我的终端命令 sudo、find 等

发布于 2024-07-14 20:20:48 字数 780 浏览 7 评论 0原文

我不知道发生了什么,但 Mac OSX 10.5 上的终端无法再找到我的 sudo 命令或 find 命令等。它们在那里是因为如果我输入 /usr/bin/sudo/usr/bin/find 它工作正常...

我的 .bash_login 文件看起来像这样:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"

我的 .bash_profile 文件看起来像这样:

export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"

我现在会说,我真的不 /em> 知道我在用终端做什么。 我只是这一切的初学者,我必须对环境变量(这就是它们的名字吗?)做了一些事情才能迷失。 我以为我只需要确保 /usr/bin/ 路径在我的 bash 文件中,但它们是,而且它似乎不起作用。 请帮忙!

另外,当我使用 /usr/bin/find 命令时,即使我以系统管理员帐户登录 Mac OSX,它也会向我显示“权限被拒绝”。 我不明白。

任何帮助都会很大。 谢谢你-詹姆斯

I don't know what has happened, but Terminal on Mac OSX 10.5 can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...

My .bash_login file looks like this:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"

My .bash_profile file looks like this:

export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"

I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must have done something to the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!

Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.

Any help would be grand. Thank you - James

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

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

发布评论

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

评论(4

慢慢从新开始 2024-07-21 20:20:49

这应该可以彻底、永久地解决问题。

首先,在终端中使用以下命令导出环境路径。

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in

现在你有了你想要的命令。 (例如,尝试ls。您将看到该命令正在运行)。 但这仅适用于当前会话。 如果您关闭终端并打开一个新终端,则会遇到上一问题。 要使此更改永久生效,请使用以下命令,

转到主目录

cd ~

,在nano / vim中打开.bash_profile文件(我在这里使用nano)

nano .bash_profile

这将打开nano编辑器。 在新行中粘贴以下内容;

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH

按“control”+“o”保存(WriteOut),按“control”+“x”退出nano。

全做完了 ! 现在尝试命令。

This should fix the problem completely and permanently.

first, export environment paths by using below command in the terminal.

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in

now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,

go to home directory

cd ~

open .bash_profile file in nano / vim (I'm using nano here)

nano .bash_profile

This will open up nano editor. In a new line, paste the following;

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH

press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.

All done ! Now try the commands.

神回复 2024-07-21 20:20:49

我遇到了同样的问题,这就是我的解决方法。

首先,我以这种方式将文件恢复为原始状态

/usr/bin/nano ~/.bash_profile

在我的情况下,我无法使任何命令别名工作。 如果不指定该命令的完整路径,即使 vi 或 vim 也无法工作。
如果没有安装nano,只需将命令中的nano替换为安装的编辑器即可,

然后重新启动计算机即可。 就我而言,正如我下面所说,我无法使用任何命令。 当尝试执行 /usr/bin/source ~/.bash_profile
该命令失败了。 所以我必须重新启动操作系统并且它起作用了

I went trough the same issue and here is how I solved it.

First of all I reverted the file to its original doing this way

/usr/bin/nano ~/.bash_profile

In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed

After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

清眉祭 2024-07-21 20:20:48

看起来您的两个 PATH 导出都格式错误:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"

末尾位不起作用。 它应该是:

export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH

注意到“$PATH”之前的冒号了吗? 这很重要;)

另外,双引号不是必需的。

如果这不起作用,我们将需要更多信息。 即使加载了 shell 配置后,其他东西也可能正在修改您的路径。

您能否发布以下结果:

$ echo $PATH

配置文件并不总是能够很好地指示当前环境变量,因为它们被整个系统中的许多程序和文件修改。 要查看所有环境变量,您可以运行:

$ env

It looks like both of your PATH exports are malformed:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"

The end bit there won't work. It should be:

export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH

Notice the colon before '$PATH'? It's important ;)

Also, the double quotes are not necessary.

If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.

Can you post the results of:

$ echo $PATH

Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:

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