如何使用macosx leopard将目录添加到$ PATH变量中 [英] How to add a directory to the $PATH variable with macosx leopard

查看:256
本文介绍了如何使用macosx leopard将目录添加到$ PATH变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的无法向$ PATH变量添加一个目录。我已经尝试添加一个文件到etc / paths.d /包含我想要添加的路径,但是操作系统反驳让我添加一个文件到该目录(权限被拒绝)。我不知道为什么,因为我以管理员身份登录...

I really am unable to add a directory to the $PATH variable. I have tried to add a file text to etc/paths.d/ containing the path i want to add, but the OS refutes to let me add a file to that directory (permission denied). I don't know why, since i login as admin...

请帮助我,我需要在macosx上添加android sdk的adb路径。 p>

Please help me, i need to add the adb path for the android sdk on macosx.

推荐答案

/etc/paths.d上的权限只允许root帐户写入,而不是正常的管理员。这在OS X中实际上是相当普遍的,因为许多用户作为管理员日常操作,但是出于安全原因,它们对于可以影响系统完整性的任何设置的写访问是不好的,要做的就是这个步骤。

The permissions on /etc/paths.d only allow the root account to write to it, not normal admins. This is actually fairly common in OS X, since many users operate day-to-day as admins, but for security reasons it's a bad idea for them to have write access to any settings that can influence system integrity without going through an explicit I-mean-to-do-that step.

那么如何添加文件?一般来说,您需要使用一个促进root来执行操作的进程。我会给出三个例子:

So how can you add a file? In general, you need to use a process that promotes to root to do the operation. I'll give three examples:


  1. 将文件创建到其他地方,然后使用Finder将其移动到位。由于/ etc通常是不可见的,因此在Finder中,您需要通过从菜单中选择Go> Go to Folder,然后输入/etc/paths.d来显式打开它。然后将文件拖动到该窗口中,它将要求您的管理员密码(用于宣传到根和移动文件)。

  2. 使用 TextWrangler 或其大哥, BBEdit (下载版本,而不是Mac App Store版本)。它们具有内置的以root身份安全存档的功能(输入管理员密码后,就像Finder)。如果您要定期操作系统配置文件,那么(IMHO)是最简单的选项。

  3. 在命令行中,您可以使用 sudo 作为以root身份运行命令的前缀(再次输入管理员密码后),例如 sudo cp mypathfile /etc/paths.d sudo vi /etc/paths.d/mypathfile.

  1. Create the file someplace else, then use the Finder to move it into place. Since /etc is normally invisible, in the Finder, you'll need to explicitly open it by choosing Go > Go to Folder from the menu, then entering "/etc/paths.d". Then just drag the file into that window, and it'll ask for your admin password (which it uses to promote to root and move the file).
  2. Use TextWrangler or its big brother, BBEdit (the download version, not the Mac App Store version). They have built-in capability to safe files as root (after entering your admin password, just like Finder). If you're going to be manipulating system config files on a regular basis, this is (IMHO) the easiest option.
  3. At the command line, you can use sudo as a prefix to run a command as root (again, after entering your admin password), e.g. sudo cp mypathfile /etc/paths.d or sudo vi /etc/paths.d/mypathfile.

这篇关于如何使用macosx leopard将目录添加到$ PATH变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆