I'm sifting through some incorrect permission issues and discovered the namei command for Linux. Homebrew doesn't currently have a Mac port.

namei - follow a pathname until a terminal point is found

Is there a command or series of commands that can be used to accomplish the same thing on OS X?

2 Answers 2


You can download the source code for namei from SourceForge. To compile, you need to delete the #include <sys/sysmacros.h> line from stat.c, then run make.

  • 1
    Thanks, I wasn't aware that the version in util-linux was based on the one from SourceForge. I did eventually figure out how to get the util-linux one to compile, but it comes with many other utilities, a lot of which are redundant on OS X. Anyways, see my updated answer for the homebrew formula of the original. Beware, installing from source with make install can cause issues if /usr/local/bin' is ahead of /usr/bin` in your PATH as it installs hardlinked to stat. The formula avoids this and only installs under namei. Apr 15, 2016 at 0:12

Macports has a port of it: https://trac.macports.org/browser/trunk/dports/devel/util-linux/Portfile

I did try to make a homebrew recipe for it, but there were some issues getting it to compile. It's definitely possible, but there are some problems to work out.


I've made a formula that can be installed with:

brew install mkdryden/homebrew-misc/namei

This is the original version, not the version pulled into util-linux. (not sure how much has changed since the original)

  • Not a homebrew expert, but does that use the file at github.com/mkdryden/homebrew-misc/blob/master/Formula/namei.rb?
    – mwfearnley
    Dec 19, 2019 at 16:09
  • @mwfearnley Yes, that's the recipe file. You can look at it to see the patch I had to make to get it to compile, though that was 5 years ago; I'm not sure if it still works properly. Dec 20, 2019 at 0:31
  • Thanks, it worked for me yesterday :)
    – mwfearnley
    Dec 20, 2019 at 10:23
  • Interestingly, today, I found namei in the Homebrew util-linux package but not in that for MacPorts.
    – huyz
    Mar 6 at 18:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .