3

I would like to edit /etc/paths file in my Mac computer.

I am a newbie and I am trying to unlock the file. I tried in Terminal to do :

etc tomasteicher$ sudo chflags nouchg /etc/paths
etc tomasteicher$ open -e /etc/paths

Almost all tutorials I have found recommend this solution. The second command open file in TextEdit but the file is still locked.

Has anybody a tip, how can I unlock file, or why this solution does not work for this file?

7

It's not actually locked, you just don't have permission to edit it. Instead, use a command-line text editor like vim to edit this file.

Use sudo vim /etc/paths to edit the file from the command line. Press i to start typing (navigate with arrow keys), press Esc when done. Then type :wq and Return


Note that in many situations, it's easier to add executable paths to a user-specific configuration file, like ~/.bash_profile, or add new files in /etc/paths.d with additional paths.

1
  • Unhelpful. I continue to get Permission denied errors when editing either /etc/paths or /etc/paths.d/macports, with sudo, after running chflags nouch <path>. – mcandre Dec 19 '17 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.