PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 18, 2022

[FIXED] How to add a directory to the $PATH variable with macosx leopard

 August 18, 2022     environment-variables, macos, path     No comments   

Issue

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

Please help me, I need to add the adb path for the Android SDK on macosx.


Solution

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.

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. 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.


Answered By - Gordon Davisson
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing