5

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?

1 Answers1

9

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.

Daniel Beck
  • 111,893