Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As far as I know, there's not a unix command that lists the permissions for a file and all of its parent directories. Is there such a thing that I'm not aware of?

share|improve this question
up vote 1 down vote accepted

For traditional Unix permissions, there is namei:

$ namei -l ~/bin/git-resurrect 

f: /home/grawity/bin/git-resurrect
drwxr-xr-x root    root    /
drwxr-xr-x root    root    home
drwxr-xr-x grawity grawity grawity
drwxr-xr-x grawity grawity bin
lrwxrwxrwx grawity grawity git-resurrect -> ../src/git/contrib/git-resurrect.sh
drwxr-xr-x grawity grawity   ..
drwxrwxr-x grawity grawity   src
drwxr-xr-x grawity grawity   git
drwxr-xr-x grawity grawity   contrib
-rwxr-xr-x grawity grawity   git-resurrect.sh

A similar program to also display POSIX ACLs:

#!/usr/bin/env perl

sub follow {
    my @items = split(m|/+|, shift);
    my @paths = ();
    my $path = "/";
    while (defined(my $item = shift @items)) {
        my $file = $path . ($path eq "/" ? "" : "/") . $item;
        if (-l $file) {
            my $target = readlink($file)
                // die "Could not read link: $!\n";
            unshift @items, split(m|/+|, $target);
            push @paths, $file;
        } else {
            push @paths, $path = $file;
        }
    }
    return @paths;
}

for my $file (@ARGV) {
    system("getfacl", "-aPpt", $_) for follow($file);
}
share|improve this answer
    
wow, awesome. That's exactly what I was looking for. Thanks! – nilbus Jan 31 '13 at 2:18

You can use a bash one-liner to list the permissions of the directory hierarchy. First change to the directory in question, and then run:

pushd .; while [ `pwd` != / ]; do ls -ld `pwd`; cd ..; done; popd
share|improve this answer

You must log in to answer this question.

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